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

[W6.1d][T15-B2] Cheng Jin Ting #917

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jin-ting
Copy link

Created isMutating method and updated Junit test

Copy link

@K1ang K1ang left a comment

Choose a reason for hiding this comment

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

@jin-ting Good attempt! Keep it up!



//Making the method abstract forces all child classes to declare whether it is a mutating command or not, rather than depend on an arbitrary decision made in the parent class.
public abstract boolean isMutating () ;
}
Copy link

Choose a reason for hiding this comment

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

A more precise phrasing is Returns true if … (instead of Checks if …)
It is better to mention it returns true if the Command potentially mutates the data (header comments specify a contract, so try to be as precise as possible). E.g. Adding a duplicate person will not mutate data but the corresponding AddCommand object will still return true for this method.
@return … line can be omitted for this method as it says the same thing as the first sentence.

@@ -85,7 +85,9 @@ public CommandResult execute(String userCommandText) throws Exception {
private CommandResult execute(Command command) throws Exception {
command.setData(addressBook, lastShownList);
CommandResult result = command.execute();
storage.save(addressBook);
if ( command.isMutating()) {
Copy link

Choose a reason for hiding this comment

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

Coding standard violations! Please refer the coding standard.

if (new Parser().parseCommand(inputCommand).isMutating()) {
assertEquals(addressBook, saveFile.load());
}

Copy link

Choose a reason for hiding this comment

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

This change doesn’t help much because it does not confirm that the saving happens only for mutating commands. Tests will pass even if you don’t have this change. To be complete, you should have an else branch that confirms the file was not updated for non mutating commands (e.g. by checking the last updated time of the file).

@K1ang K1ang added the Reviewed label Oct 8, 2017
@K1ang
Copy link

K1ang commented Oct 8, 2017

Some comments added. Please close the PR after reading comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants