-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
AddressBook: remove master tag list #383 #385
Conversation
Click here to submit a new iteration when this PR is ready for review. See this repository's contribution guide for more information. |
3bda739
to
891108c
Compare
v1@yamidark submitted v1 for review.
Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level2.git refs/pr/385/1/head:BRANCHNAME where |
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.
[2/4] imports were not 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.
duplicate, please ignore
891108c
to
48ab4cf
Compare
v2@yamidark submitted v2 for review.
(📚 Archive) (📈 Interdiff between v1 and v2) (📈 Range-Diff between v1 and v2) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level2.git refs/pr/385/2/head:BRANCHNAME where |
@@ -26,7 +26,7 @@ | |||
|
|||
public class AddCommandTest { | |||
private static final List<ReadOnlyPerson> EMPTY_PERSON_LIST = Collections.emptyList(); | |||
private static final Set<String> EMPTY_STRING_LIST = Collections.emptySet(); | |||
private static final Set<String> EMPTY_STRING_LIST = new HashSet<>(); |
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.
[3/4] is this change necessary? i think the intention was to be immutable.
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.
Hmm, I think I did a mass replacement for this, didn't notice it changed here as well.
Anyway, since the Person
constructor now directly sets the tags
, thought it would be safer to ensure that the Set
we supply is mutable from the start.
Perhaps would be better if we make Person
hold its own mutable copy Set
from the start, and make it add the Tag
s in, like in UniqueTagList
?
@yamidark Can squash [1/4] and [2/4]? [1/4] makes no sense without [2/4], as [2/4] deletes huge chunks of code that were touched in [1/4]. I'm not quite sure about the deletions of some test cases in btw, [1/4]'s commit message:
Should be se-edu/addressbook-level4#825 I think.
|
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.
[3/4]
this.name = name; | ||
this.phone = phone; | ||
this.email = email; | ||
this.address = address; | ||
this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list | ||
this.tags = tags; |
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.
Should be:
this.tags = new HashSet<>(tags);
so that the Person
will have a Set
which it has full ownership of, and can't be modified externally (preserves encapsulation).
Can copy from AB-4:
@@ -33,14 +33,14 @@ | |||
@Before | |||
public void setUp() throws Exception { | |||
Person johnDoe = new Person(new Name("John Doe"), new Phone("61234567", false), | |||
new Email("[email protected]", false), new Address("395C Ben Road", false), new UniqueTagList()); | |||
new Email("[email protected]", false), new Address("395C Ben Road", false), new HashSet<>()); |
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.
Does the new constructor you introduced help here?
public Person(Name name, Phone phone, Email email, Address address, Tag... tags)
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.
On second thought, I think you should remove the constructor. AB-4 doesn't have it.
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.
The new constructor was added to replace the UniqueTagList
constructor:
public UniqueTagList(Tag... tags)
which AB4 doesn't have.
Although this is only used in tests, so I wouldn't really mind removing it as well to be consistent with AB4.
dan = new Person(new Name("Dan Smith"), new Phone("1234556", true), new Email("[email protected]", true), | ||
new Address("NUS", true), new UniqueTagList(new Tag("Test"))); | ||
new Address("NUS", true), new HashSet<>()); |
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.
Why was the new Tag("Test")
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.
Whoops, didn't notice this
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.
[4/4]
mainClassDiagram.png
:
AB-4 puts the Person
->Tag
arrow as part of the filled diamond (composition), so it should probably be the same to be consistent. (I assume @damithc vetted AB-4's version already)
If that is so, [LO-Composition]
should be updated to include Tag
in the example of composition (filled diamond) as well.
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.
Changes Requested.
This wasn't very fun to review due to all the subtle differences between the different ABs. </rant> |
be4a8db
to
23672d5
Compare
We keep track of a master tag list which holds all the tags in AddressBook. As the master tag list was deemed unnecessary and may be too complex for new developers to grasp, as discussed in se-edu/addressbook-level4#753 and se-edu/addressbook-level4#794, the master tag list has already been removed in addressbook-level4 in se-edu/addressbook-level4#825. As such, the master tag list should also be removed here for consistency. Let's remove the master tag list in AddressBook. Similarly, it is now unnecessary for AdaptedAddressBook to store a master tag list as well. Let's remove the master tag list in AdaptedAddressBook.
Many methods in UniqueTagList, such as mergeFrom(UniqueTagList), were previously used by only the AddressBook for the master tag list. Since AddressBook does not use a master tag list anymore, all these methods are no longer necessary. UniqueTagList now only serves to add complexity to the code base. Let's remove the UniqueTagList class, and update Person to use a Set instead for holding its tags instead, since it can only contain unique elements.
06d8367
to
55f8424
Compare
v3@yamidark submitted v3 for review.
(📚 Archive) (📈 Interdiff between v2 and v3) (📈 Range-Diff between v2 and v3) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level2.git refs/pr/385/3/head:BRANCHNAME where |
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.
eh... in [4/4] Exercise: Add an Association Class Tagging
how come tag used a special purple color?
|
||
davidElliot = new Person(new Name("David Elliot"), | ||
new Phone("84512575", false), | ||
new Email("[email protected]", false), | ||
new Address("11 Arts Link", false), | ||
new UniqueTagList(tagEconomist, tagPrizeWinner)); | ||
new HashSet<>(Arrays.asList(tagEconomist, tagPrizeWinner))); |
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.
[2/4] If want to make it immutable, Set.of(...)
would probably be a better option.
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 is currently still in Java 8, so Set.of(...)
is still not available yet 😞.
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.
oh... crap lol
|
I thought it was originally orange?! |
Yep, I changed it to purple to be consistent with the rest of the Oh, just noticed that Updated diagram here |
Thanks, didnt notice that. In this case... I think this line |
Ehh, as the method is modifying the instance-level variable |
PS, I actually mean that that line doesn't really serve a purpose anymore because prior to this change, it was distinct from the other members because we had a master list and Perhaps, we should rephrase it abit to like |
Yep, sounds good. Will do that in the next iteration. |
55f8424
to
7bf1433
Compare
v4@yamidark submitted v4 for review.
(📚 Archive) (📈 Interdiff between v3 and v4) (📈 Range-Diff between v3 and v4) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level2.git refs/pr/385/4/head:BRANCHNAME where |
[3/4]
Maybe, but how does this weigh against keeping consistent with AB-4 (which does not have such a change?) Let's refrain from making too many creative changes and drop [3/4]? We are pretty short of time. |
AddressBook previously had a UniqueTagList linked to it as the master tag list, which was reflected in the architecture diagrams in the DeveloperGuide and LearningOutcomes. Since AddressBook does not use a master tag list anymore, and UniqueTagList has been removed, these architecture diagrams are no longer consistent with the program. Let's update these architecture diagrams in the DeveloperGuide and LearningOutcomes.
7bf1433
to
756dccc
Compare
v5@yamidark submitted v5 for review.
(📚 Archive) (📈 Interdiff between v4 and v5) (📈 Range-Diff between v4 and v5) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level2.git refs/pr/385/5/head:BRANCHNAME where |
Fixes #383