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

AddressBook: remove master tag list #383 #385

Merged
merged 3 commits into from
Aug 8, 2018

Conversation

yamidark
Copy link
Contributor

@yamidark yamidark commented Aug 6, 2018

Fixes #383

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 AB4
by se-edu/addressbook-level4#825. 

UniqueTagList was also deemed unnecessary and removed in
addressbook-level4 after the master tag list is removed.

As such, the master tag list and UniqueTagList class should also be
removed in the lower level projects.

Let's remove the master tag list in AddressBook and AdaptedAddressBook,
as well as the UniqueTagList class.

@CanIHasReview-bot
Copy link

Click here to submit a new iteration when this PR is ready for review.

See this repository's contribution guide for more information.

@yamidark yamidark force-pushed the 383-remove-master-tag-list branch from 3bda739 to 891108c Compare August 6, 2018 19:10
@CanIHasReview-bot
Copy link

v1

@yamidark submitted v1 for review.

(📚 Archive)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level2.git refs/pr/385/1/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

@yamidark yamidark requested a review from a team August 6, 2018 19:12
Copy link
Member

@eugenepeh eugenepeh left a 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.

Copy link
Member

@eugenepeh eugenepeh left a comment

Choose a reason for hiding this comment

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

duplicate, please ignore

@yamidark yamidark force-pushed the 383-remove-master-tag-list branch from 891108c to 48ab4cf Compare August 7, 2018 09:39
@CanIHasReview-bot
Copy link

v2

@yamidark submitted v2 for review.

(📚 Archive) (📈 Interdiff between v1 and v2) (📈 Range-Diff between v1 and v2)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level2.git refs/pr/385/2/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

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

@eugenepeh eugenepeh Aug 7, 2018

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.

Copy link
Contributor Author

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 Tags in, like in UniqueTagList?

@pyokagan
Copy link
Contributor

pyokagan commented Aug 7, 2018

@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 AddressBookTest, like addPerson_emptyAddressBook, but I also don't quite mind given the time constraints.

btw, [1/4]'s commit message:

AddressBook: remove master tag list

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#824. As such, the master tag list

Should be se-edu/addressbook-level4#825 I think.

should also be removed here for consistency.

Let's remove the master tag list in AddressBook.

Copy link
Contributor

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

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:

https://github.com/se-edu/addressbook-level4/blob/e186102b646d2307b53928142dd22932a6f4c86d/src/main/java/seedu/address/model/person/Person.java#L25-L37

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

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)

Copy link
Contributor

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.

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

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

Copy link
Contributor

@pyokagan pyokagan left a 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.

Copy link
Contributor

@pyokagan pyokagan left a comment

Choose a reason for hiding this comment

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

Changes Requested.

@pyokagan
Copy link
Contributor

pyokagan commented Aug 7, 2018

This wasn't very fun to review due to all the subtle differences between the different ABs. </rant>

@yamidark yamidark force-pushed the 383-remove-master-tag-list branch 5 times, most recently from be4a8db to 23672d5 Compare August 7, 2018 16:11
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.
@yamidark yamidark force-pushed the 383-remove-master-tag-list branch 3 times, most recently from 06d8367 to 55f8424 Compare August 7, 2018 16:19
@CanIHasReview-bot
Copy link

v3

@yamidark submitted v3 for review.

(📚 Archive) (📈 Interdiff between v2 and v3) (📈 Range-Diff between v2 and v3)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level2.git refs/pr/385/3/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

Copy link
Member

@eugenepeh eugenepeh left a 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)));
Copy link
Member

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.

Copy link
Contributor Author

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 😞.

Copy link
Member

Choose a reason for hiding this comment

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

oh... crap lol

@yamidark
Copy link
Contributor Author

yamidark commented Aug 7, 2018

eh... how come tag used a special purple color?

Tag is now strongly part of Person, so should have the same colour as the rest of the fields.
Although not too sure if should keep the original colour for the LO Taggings =x (yep, looks weird with that single purple box inside).

@eugenepeh
Copy link
Member

Tag is now strongly part of Person, so should have the same colour as the rest of the fields.
Although not too sure if should keep the original colour for the LO Taggings =x (yep, looks weird with that single purple box inside).

I thought it was originally orange?!

@yamidark
Copy link
Contributor Author

yamidark commented Aug 7, 2018

I thought it was originally orange?!

Yep, I changed it to purple to be consistent with the rest of the Person fields (in DeveloperGuide).

Oh, just noticed that DeveloperGuide wasn't updated in this PR at all, just changed the diagram, since you probably didn't notice it.

Updated diagram here

@eugenepeh
Copy link
Member

Oh, just noticed that DeveloperGuide wasn't updated in this PR at all, just changed the diagram, since you probably didn't notice it.

Thanks, didnt notice that.

In this case... I think this line Note how the setTags method of the Person class cannot be converted to a class-level method. in LO is obsolete?

@yamidark
Copy link
Contributor Author

yamidark commented Aug 7, 2018

Note how the setTags method of the Person class cannot be converted to a class-level method.

Ehh, as the method is modifying the instance-level variable tags, the setTags method still cannot be converted to class-level right?

@eugenepeh
Copy link
Member

eugenepeh commented Aug 7, 2018

Ehh, as the method is modifying the instance-level variable tags, the setTags method still cannot be converted to class-level right?

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 Tags was not part of Person. But now it is no different from name... address... etc. So it brings up question like whats so special about setTags?

Perhaps, we should rephrase it abit to like For example, instead of Note?

@yamidark
Copy link
Contributor Author

yamidark commented Aug 7, 2018

Perhaps, we should rephrase it abit to like For example, instead of Note?

Yep, sounds good. Will do that in the next iteration.
Maybe like this:
Note how some instance-level methods, such as the setTags methods of the Person class, cannot be converted to a class-level method.

@yamidark yamidark force-pushed the 383-remove-master-tag-list branch from 55f8424 to 7bf1433 Compare August 8, 2018 06:25
@CanIHasReview-bot
Copy link

v4

@yamidark submitted v4 for review.

(📚 Archive) (📈 Interdiff between v3 and v4) (📈 Range-Diff between v3 and v4)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level2.git refs/pr/385/4/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

@pyokagan
Copy link
Contributor

pyokagan commented Aug 8, 2018

[3/4]

Tag: move Tag from data/tag to data/person package

AddressBook used to have a master tag list, which stores
the tag held by each Person.

As the master tag list has been removed, Tag is now strongly
part of Person. As such, Tag should be under data/person
package as well.

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.
@yamidark yamidark force-pushed the 383-remove-master-tag-list branch from 7bf1433 to 756dccc Compare August 8, 2018 08:13
@CanIHasReview-bot
Copy link

v5

@yamidark submitted v5 for review.

(📚 Archive) (📈 Interdiff between v4 and v5) (📈 Range-Diff between v4 and v5)

Checkout this PR version locally
git fetch https://github.com/se-edu/addressbook-level2.git refs/pr/385/5/head:BRANCHNAME

where BRANCHNAME is the name of the local branch you wish to fetch this PR to.

@yamidark yamidark requested a review from damithc August 8, 2018 09:50
@pyokagan pyokagan merged commit ba89e36 into se-edu:master Aug 8, 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.

5 participants