Skip to content
This repository was archived by the owner on Feb 28, 2022. It is now read-only.

Refactoring #10

Open
sornas opened this issue Nov 16, 2020 · 3 comments
Open

Refactoring #10

sornas opened this issue Nov 16, 2020 · 3 comments

Comments

@sornas
Copy link
Member

sornas commented Nov 16, 2020

The code as it stands is not the best. Current issues:

  • Code duplication when sending messages
  • Very deep indentation in some places

Other suggestions:

  • Clearer abstractions
@sornas
Copy link
Member Author

sornas commented Nov 18, 2020

parse_message could take a closure that sends a message.

@FredTheDino
Copy link
Contributor

parse_message should maybe use the "match" functionality? You can make it a lot more declarative. If we split the string upto the first space can simplify a lot of the code from what I've seen. Maybe a dict mapped to a function that takes the rest of the string? Closures might be overkill...

@sornas
Copy link
Member Author

sornas commented Nov 18, 2020

The closure is for sending response messages. I just pushed 4568425 that does this. It opens up the return type for parse_message which otherwise would have been an almost-too-complex enum containing some like

pub enum ParseResponse {
    SendMessage(String),
    EmojiOk,
    EmojiErr,
    // ...
}

Parsing commands in a better way is definitely on the todo however.

@sornas sornas linked a pull request Dec 6, 2020 that will close this issue
2 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants