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

[T2A2][T16-A3][Edward Tan Wei Chong] #282

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

Conversation

EdCS2103
Copy link

@EdCS2103 EdCS2103 commented Feb 1, 2017

No description provided.

@EdCS2103
Copy link
Author

EdCS2103 commented Feb 1, 2017

Ready for review

Copy link

@sooyj sooyj left a 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;
Copy link

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];
Copy link

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);
Copy link

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);
Copy link

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, "");
Copy link

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
Copy link

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

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.

@sooyj sooyj added the Reviewed label Feb 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants