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

[W6.2i][T09-4] Vincent Neo #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

[W6.2i][T09-4] Vincent Neo #125

wants to merge 1 commit into from

Conversation

tenvinc
Copy link

@tenvinc tenvinc commented Sep 19, 2018

[Addressbook-Level3: LO-Interfaces]

…at returns String. Also added a function in Person to combine the printables into 1 string and called the function during view command
Copy link

@RubaP RubaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Please take note of the comments and close this PR


public static final String EXAMPLE = "123, some street";
public static final String MESSAGE_ADDRESS_CONSTRAINTS = "Person addresses can be in any format";
public static final String ADDRESS_VALIDATION_REGEX = ".+";
public static final String ADDRESS_PRINTABLE_LABEL = "ADDRESS";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job on extracting out the label as a constant

* A read-only immutable interface for any field that can be printed in the addressbook.
* Implementations should guarantee: details are present and not null, field values are validated.
*/
public interface Printable {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job on adding header comments for both Class and method

@@ -61,6 +61,15 @@ public Address getAddress() {
return new HashSet<>(tags);
}

public String getPrintableString(Printable ...printables){
String printableString = printables[0].getPrintableString();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct. But to be consistent with all the instances in the list, you may create a default string and update while iterating the entire list. This will help you in future in case if you want to do something else within the loop for all the elements in the array

@@ -21,6 +21,8 @@
*/
Set<Tag> getTags();

String getAsTextNoRestrictions();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may have the implementation here rather than in Person since printing does not mutate the data (Any behaviour that does not mutate the Person can be kept in ReadOnlyPerson)

@@ -55,4 +56,8 @@ public int hashCode() {
public boolean isPrivate() {
return isPrivate;
}

public String getPrintableString() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to have the @OverRide keyword to explicitly specify to the reader that this is an overridden method. Moreover, if you make a common mistake of misspelling a method name or not correctly matching the parameters, you will be warned.

@@ -32,7 +32,7 @@ public CommandResult execute() {
if (!addressBook.containsPerson(target)) {
return new CommandResult(Messages.MESSAGE_PERSON_NOT_IN_ADDRESSBOOK);
}
return new CommandResult(String.format(MESSAGE_VIEW_PERSON_DETAILS, target.getAsTextHidePrivate()));
return new CommandResult(String.format(MESSAGE_VIEW_PERSON_DETAILS, target.getAsTextNoRestrictions()));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that you attempted to use the getPrintableString with this new method. However, this changes the behavior of View command. Please note that going forward you need to update the tests as well when you make any behavior changes.

@RubaP RubaP added the Reviewed label Sep 22, 2018
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.

3 participants