-
Notifications
You must be signed in to change notification settings - Fork 111
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
[T2A2][T16-A3][Edward Tan Wei Chong] #282
base: master
Are you sure you want to change the base?
Conversation
Ready for review |
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.
Overall a very good attempt!
@@ -54,7 +58,7 @@ | |||
/** | |||
* A platform independent line separator. | |||
*/ | |||
private static final String LS = System.lineSeparator() + LINE_PREFIX; | |||
private static final String LINE_SEPERATOR = System.lineSeparator() + LINE_PREFIX; |
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 call.
@@ -366,8 +374,8 @@ private static void loadDataFromStorage() { | |||
*/ | |||
private static String executeCommand(String userInputString) { | |||
final String[] commandTypeAndParams = splitCommandWordAndArgs(userInputString); | |||
final String commandType = commandTypeAndParams[0]; | |||
final String commandArgs = commandTypeAndParams[1]; | |||
final String commandType = commandTypeAndParams[COMMAND_TYPE_INDEX]; |
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: Removal of magic number.
if (!Collections.disjoint(wordsInName, keywords)) { | ||
matchedPersons.add(person); | ||
} | ||
addMatchedPerson(keywords, matchedPersons, person, wordsInName); |
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 method extraction is arguable. :-)
@@ -794,11 +807,11 @@ private static void addPersonToAddressBook(String[] person) { | |||
* @return true if the given person was found and deleted in the model | |||
*/ | |||
private static boolean deletePersonFromAddressBook(String[] exactPerson) { | |||
final boolean changed = ALL_PERSONS.remove(exactPerson); | |||
if (changed) { | |||
final boolean isChanged = ALL_PERSONS.remove(exactPerson); |
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: Boolean variable naming convention.
private static String removePrefixSign(String s, String sign) { | ||
return s.replace(sign, ""); | ||
private static String removePrefix(String fullString, String prefix) { | ||
return fullString.replace(prefix, ""); |
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.
Code logic is not corrected. replace() changes all occurrences of the prefix string in fullString. The intention is to remove the first occurrence only.
* @param s Parameter as a string | ||
* @param sign Parameter sign to be removed | ||
* @param fullString Parameter as a string | ||
* @param prefix Parameter sign to be removed |
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.
Correct to update the comment. Note that you should remove the mention of "sign" in this comment too.
@@ -989,12 +1002,12 @@ private static String extractPhoneFromPersonString(String encoded) { | |||
|
|||
// phone is last arg, target is from prefix to end of string | |||
if (indexOfPhonePrefix > indexOfEmailPrefix) { | |||
return removePrefixSign(encoded.substring(indexOfPhonePrefix, encoded.length()).trim(), | |||
return removePrefix(encoded.substring(indexOfPhonePrefix, encoded.length()).trim(), |
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 change. Removed the ambiguous term "sign" from method name.
No description provided.