-
Notifications
You must be signed in to change notification settings - Fork 113
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
[W5][W17-3]Jeremy Loye #160
base: master
Are you sure you want to change the base?
Conversation
For consistency, it should be "We hope to see you again soon!" The h in "hope" should be lower case. |
Great that you updated expected.txt after making the changes |
Removing the double negatives makes the code easier to read and understand. |
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.
Points to note:
- It's good to be on the lookout for double negatives, but don't get them confused with guard clauses. Guard clauses is important because it keeps the main path un-indented.
- Good job fixing the expected test output.
@@ -29,10 +29,10 @@ public ViewAllCommand(int targetVisibleIndex) { | |||
public CommandResult execute() { | |||
try { | |||
final ReadOnlyPerson target = getTargetPerson(); | |||
if (!addressBook.containsPerson(target)) { |
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.
This here is not an example of double negative. Double negative refers to having multiple negations in the conditional (e.g. !isNotFound), and does not refer to the case of using a negated condition to represent an unusual branch.
Instead, this is a guard clause, which is used here to detect an unusual condition (i.e. the target not being found in the address book). The reason for doing this is to make the 'happy path' prominent (i.e. the target being found). You can refer to the textbook chapter: https://nus-cs2103-ay1819s2.github.io/cs2103-website/se-book-adapted/chapters/codeQuality.html.
@@ -237,15 +237,15 @@ private int parseArgsAsDisplayedIndex(String args) throws ParseException, Number | |||
*/ | |||
private Command prepareFind(String args) { | |||
final Matcher matcher = KEYWORDS_ARGS_FORMAT.matcher(args.trim()); | |||
if (!matcher.matches()) { |
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.
No need to refactor this. Refer to the other comment about guard clauses.
-Refactored Parser prepareFind method to remove double negative
-Refactored viewAllCommand execute method to remove double negative
-Changed MESSAGE_GOODBYE message from "Good bye!" to "Good bye! We Hope to see you again soon!"