-
Notifications
You must be signed in to change notification settings - Fork 73
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.2b][T09-4] Vincent Neo #122
base: master
Are you sure you want to change the base?
Conversation
… in every class inheriting from Command
Hi @tenvinc, your pull request title is invalid. For PR sent to satisfy a learning outcome, the PR name should be in the format of For team PR, the PR name should be in the format of Please follow the above format strictly and edit your title for reprocessing. Note: this comment is posted by a bot. If you believe this is done in error, please create an issue at nus-se-pr-bot and add a link to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! Please note that going forward you need to update the tests as well when you make any behaviour changes. Please go through the comments and close this PR
@@ -70,4 +70,6 @@ public int getTargetIndex() { | |||
public void setTargetIndex(int targetIndex) { | |||
this.targetIndex = targetIndex; | |||
} | |||
|
|||
public abstract boolean isMutating(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better you add a header comment to both this method and overriding methods since this method returns a very sensitive information and method name does not give the complete picture of the responsibility.
@@ -85,7 +85,8 @@ 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()) | |||
storage.save(addressBook); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though the curly braces are not required, still it is encouraged to use to increase the readability of the code
@@ -85,7 +85,8 @@ public CommandResult execute(String userCommandText) throws Exception { | |||
private CommandResult execute(Command command) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to update the header comment of this method as the behavior of execute changes due to the way data is saved
LO for polymorphism