Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor/1697 introduce parse function which returns ParsedCommand #1698

Merged
merged 6 commits into from
Jan 13, 2021

Conversation

JonasCir
Copy link
Member

@JonasCir JonasCir commented Jan 9, 2021

Closes #1697
By this, the call site in InputController.js gets more readable.
Consider this PR as a trick to reduce the diff of the following PR. Once this is merged, I can start to separate the parsing process from the command that is returned and handled.

@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 20:37 Inactive
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 21:24 Inactive
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 21:45 Inactive
@JonasCir JonasCir marked this pull request as draft January 9, 2021 22:03
@JonasCir
Copy link
Member Author

JonasCir commented Jan 9, 2021

I just had an idea...

Copy link
Member

@n8rzz n8rzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure I understand the name change here. CommandParser describes and action. It does something that the name describes. ParsedCommand, however, suggests a thing has already been done. This name describes an immutable thing.

Perhaps that’s the direction? I want to call it out now, tho, cause naming is incredibly important.

@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 22:16 Inactive
@JonasCir
Copy link
Member Author

JonasCir commented Jan 9, 2021

@n8rzz Your totally right, I updated the PR now such that there is an actual parse method in the parser which returns the ParsedCommand. This should be more intuitive and provides us with a clean interface.

@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 22:21 Inactive
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 22:24 Inactive
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 22:29 Inactive
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 22:38 Inactive
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 22:44 Inactive
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 22:46 Inactive
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 22:50 Inactive
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 23:01 Inactive
@JonasCir JonasCir changed the title refactor/1697 rename CommandParser -> ParsedCommand refactor/1697 introduce parse function which returns ParsedCommand Jan 9, 2021
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 23:24 Inactive
@JonasCir JonasCir marked this pull request as ready for review January 9, 2021 23:34
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 23:35 Inactive
@JonasCir JonasCir requested a review from n8rzz January 9, 2021 23:37
@JonasCir
Copy link
Member Author

JonasCir commented Jan 9, 2021

This is better :) The parser logic is now separated from the command that is returned.

@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 9, 2021 23:43 Inactive
@erikquinn erikquinn added the refactor Code changes that neither fix a defect nor add functionality label Jan 10, 2021
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 10, 2021 09:15 Inactive
@JonasCir JonasCir requested a review from n8rzz January 10, 2021 09:16
Copy link
Member

@n8rzz n8rzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple small things and you’re good to go.


if (aircraftCommandParser.command !== PARSED_COMMAND_NAME.TRANSMIT) {
return this.processSystemCommand(aircraftCommandParser);
const parsedCommand = cmd;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we reassigning here? Could we continue to use cmd?

Copy link
Member Author

@JonasCir JonasCir Jan 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reason is that I want the parsed command to be const, but I cannot do it in the try block as it is then only scoped to the block. To make it const, I need to trick and use a reassign here.

test/commands/ParsedCommand.spec.js Outdated Show resolved Hide resolved
@JonasCir JonasCir requested a review from n8rzz January 10, 2021 19:20
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 10, 2021 19:23 Inactive
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 13, 2021 03:10 Inactive
@erikquinn erikquinn temporarily deployed to openscope-pr-1698 January 13, 2021 03:11 Inactive
@erikquinn erikquinn merged commit 0f076e2 into develop Jan 13, 2021
@erikquinn erikquinn deleted the refactor/1697 branch January 13, 2021 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code changes that neither fix a defect nor add functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce parse function which returns ParsedCommand
3 participants