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

[W5][W17-3]Jeremy Loye #160

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JeremyLoye
Copy link

-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!"

  • Changed expected output to reflect changes in message

@eugeneyl
Copy link

For consistency, it should be "We hope to see you again soon!" The h in "hope" should be lower case.

@kjiaxuan
Copy link

Great that you updated expected.txt after making the changes

@geezlouisee
Copy link

Removing the double negatives makes the code easier to read and understand.

Copy link

@adamwth adamwth left a 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)) {
Copy link

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()) {
Copy link

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.

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.

6 participants