-
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::addTag() is not used #169 #179
Conversation
@PierceAndy, thanks for your PR! By analyzing the history of the files in this pull request, we identified @YijinL, @thenaesh and @yamgent to be potential reviewers. |
b81b6c8
to
033e8be
Compare
v1@PierceAndy submitted v1 for review.
Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level2.git refs/pr/179/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.
[v1 1/3]
commands that support the addition of Tags only; is not part of any
learning objectives; and AddressBook#syncTagsWithMasterList() already
handles the addition of Tags from a Person gracefully without using
exceptions.
Not a grammar guru, but it seems weird to use semi-colons here instead of commas
and a fullstop. Perhaps it is because of the missing subject and the use of and
?
Maybe something like this might read a bit better:
commands that support the addition of Tags only. It is not part of any
learning objectives, and AddressBook#syncTagsWithMasterList()...
* | ||
* @throws DuplicateTagException if the Tag to add is a duplicate of an existing Tag in the list. | ||
*/ | ||
public void add(Tag toAdd) throws DuplicateTagException { |
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.
Nice spot, but this should probably be in a separate commit because [v1 1/3] is about AddressBook#addTag()
, not UniqueTagList#add()
.
Also, not sure whether it is a good reason to remove UniqueTagList#add()
just because AddressBook#addTag()
no longer exist, since I can understand that you are not supposed to manipulate AddressBook
's tags directly, but I don't expect UniqueTagList
to no longer allow adding new tags as a result. @chao1995 Your thoughts on 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.
AddressBook#addTag()
is the only method that uses UniqueTagList#add()
, and similarly so with remove in [v1 2/3]. Of course, I can understand the arguments for having a separate issue + PR for unused methods in UniqueTagList.
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.
Actually I meant having a separate commit in this current PR, not a separate PR.
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 should probably be in a separate commit
Agree.
whether it is a good reason to remove UniqueTagList#add() just because AddressBook#addTag() no longer exist
Since UniqueTagList#add() is never used as well. I would suggest we remove 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.
[v1 2/3]
* | ||
* @throws TagNotFoundException if no such Tag could be found in the list. | ||
*/ | ||
public void remove(Tag toRemove) throws TagNotFoundException { |
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.
Same concern as [v1 1/3].
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.
[v1 3/3]
assertFalse(defaultAddressBook.containsTag(tagEconomist)); | ||
assertFalse(defaultAddressBook.containsTag(tagPrizeWinner)); | ||
assertFalse(defaultAddressBook.getAllTags().contains(tagEconomist)); | ||
assertFalse(defaultAddressBook.getAllTags().contains(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.
@PierceAndy I assume that you are talking about this one in the OP of the PR.
Since containsTag()
is only used in testing, and we are removing it, this alternative looks acceptable. However, it seems that we also have a method AddressBookTest#isTagObjectInAddressBookList()
that also allow us to check the tags in the AddressBook (like how it used in line 100). Maybe consider using that instead?
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.
Yes, it does make sense to use that and be consistent.
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 (as above)
EDIT: I edited my review regarding the commit message to make it more clear (and also removed an irrelevant part).
@yamgent About the use of semi-colons, yes it's possible to use semi-colons in place of commas as a kind of "super-comma" when your list is complex. As to whether it's good practice, I guess I might reconsider 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.
No additional comment. Can proceed to next iteration.
033e8be
to
ecb4d74
Compare
v2@PierceAndy submitted v2 for review.
(📚 Archive) (📈 Interdiff between v1 and v2) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level2.git refs/pr/179/2/head:BRANCHNAME where |
v2
|
ecb4d74
to
a5ed663
Compare
v3@PierceAndy submitted v3 for review.
(📚 Archive) (📈 Interdiff between v2 and v3) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level2.git refs/pr/179/3/head:BRANCHNAME where |
v3
|
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.
Ok, they do look better with the new flow.
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.
LGTM.
This PR has two approved peer reviews. Proceeding with next round of reviews with senior dev. |
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.
Looks like tests are missing some verifications, but unrelated to this PR. Probably need to fix separately. Create an issue?
defaultAddressBook.addPerson(davidElliot); | ||
assertTrue(defaultAddressBook.containsTag(tagEconomist)); | ||
assertTrue(defaultAddressBook.containsTag(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.
Noticed something odd here. The test does not confirm that the person is added correctly.
Just a side note: I just realised that |
Oh yes. That was why the method was added in the first place (to confirm the |
Yes, agreed. In light of this new |
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.
[v3 5/5]
AddressBook: remove unused containsTag()
AddressBook#containsTag() checks if a given Tag is in the master list of
Tags.This method is not used anywhere, and can be classified as unused code.
There are no commands that support it, and it is also not part of any
learning objectives. While it is used in two tests for
AddressBook#addPerson(), it should be replaced with the existing
AddressBookTest#isTagObjectInAddressBookList() to improve code reuse.
So this is misleading -- we aren't actually reusing code, since
AddressBookTest#isTagObjectInAddressBookList()
isn't an equivalent
replacement for AddressBook#addPerson()
.
AddressBook#containsTag() should be removed as unused code contributes
to maintenance and comprehension overheads.Let's remove AddressBook#containsTag().
AddressBook#addTag() adds a Tag to the master list of Tags in AddressBook. This method is not used anywhere, and can be classified as unused code. There are no commands that support the addition of Tags only, and it is also not part of any learning objectives. Furthermore, AddressBook#syncTagsWithMasterList() already handles the addition of Tags from a Person gracefully without using exceptions. It should be removed as unused code contributes to maintenance and comprehension overheads. Let's remove AddressBook#addTag().
UniqueTagList#add() adds a Tag to the list of unique Tags, and throws an exception if it is a duplicate of an existing Tag in the list. With the removal of AddressBook#addTag(), this method is not used anywhere, and can be classified as unused code. It should be removed as unused code contributes to maintenance and comprehension overheads. Let's remove UniqueTagList#add().
AddressBook#removeTag() removes a Tag from the master list of Tags and from any Person in AddressBook. This method is not used anywhere, and can be classified as unused code. There are no commands that support the removal of Tags only, and it is also not part of any learning objectives. It should be removed as unused code contributes to maintenance and comprehension overheads. Let's remove AddressBook#removeTag().
UniqueTagList#remove() removes a Tag from the list of unique Tags, and throws an exception if it is not found in the list. With the removal of AddressBook#removeTag(), this method is not used anywhere, and can be classified as unused code. It should be removed as unused code contributes to maintenance and comprehension overheads. Let's remove UniqueTagList#remove().
022c23d
to
4cfe9a5
Compare
v4@PierceAndy submitted v4 for review.
(📚 Archive) (📈 Interdiff between v3 and v4) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level2.git refs/pr/179/4/head:BRANCHNAME where |
v4
|
Tried to shorten the commit message. Does it cover all the points?
|
AddressBook#containsTag() checks if the master list of Tags contains a Tag with the same value as the given Tag. AddressBook#containsTag() is not used in the production code. While it is used in test code, its use can be replaced by AddressBookTest#isTagObjectInAddressBookList(). Let's remove AddressBook#containsTag(). Notes: * Why not keep AddressBook#containsTag() and remove AddressBookTest#isTagObjectInAddressBookList() instead? The former does a value equality test while the latter goes further and does a reference equality test. The test code requires a reference equality test to verify Person objects refer to Tag objects in the common tag list instead of keeping its own copies of Tag objects. * Why not change AddressBook#containsTag() to use reference equality and use that in tests? Doing so will make AddressBook#containsTag()'s semantics inconsistent with the rest of our API.
4cfe9a5
to
a6cc952
Compare
v5@PierceAndy submitted v5 for review.
(📚 Archive) (📈 Interdiff between v4 and v5) Checkout this PR version locallygit fetch https://github.com/se-edu/addressbook-level2.git refs/pr/179/5/head:BRANCHNAME where |
v5
|
Fixes #169
Removed unused tag level methods in AddressBook:
@yamgent @chao1995 With your unit test experiences, what are your thoughts on how tests that relied on containsTag() were handled?