-
Notifications
You must be signed in to change notification settings - Fork 185
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,9 @@ public CommandResult execute() { | |
} | ||
} | ||
|
||
@Override | ||
public boolean isMutating () { | ||
return true ; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coding standard violations! Please refer the coding standard. |
||
storage.save(addressBook); | ||
} | ||
return result; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
import seedu.addressbook.data.tag.Tag; | ||
import seedu.addressbook.data.tag.UniqueTagList; | ||
import seedu.addressbook.storage.StorageFile; | ||
import seedu.addressbook.parser.Parser; | ||
|
||
import java.util.*; | ||
|
||
|
@@ -90,7 +91,11 @@ private void assertCommandBehavior(String inputCommand, | |
//Confirm the state of data is as expected | ||
assertEquals(expectedAddressBook, addressBook); | ||
assertEquals(lastShownList, logic.getLastShownList()); | ||
assertEquals(addressBook, saveFile.load()); | ||
//to create a new Command instance | ||
if (new Parser().parseCommand(inputCommand).isMutating()) { | ||
assertEquals(addressBook, saveFile.load()); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
} | ||
|
||
|
||
|
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.
A more precise phrasing is
Returns true if …
(instead ofChecks 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.