From 988c177ff7a9b0d228c0135a3dff5ece1a4ae861 Mon Sep 17 00:00:00 2001 From: aditi2313 <52269537+aditi2313@users.noreply.github.com> Date: Fri, 25 Feb 2022 01:02:17 +0800 Subject: [PATCH] Update isSamePerson() equality for Person class The person equality check returns true if the name or the email matches. The OR condition complicates the equality check done when editing a person as it assumes isSamePerson() to have a transitive relation. Alternative 1: Improve the way the equality check is done in the edit command to prevent the above bug. (PRs nus-cs2103-AY2122S2#68, nus-cs2103-AY2122S2#69) Alternative 2: Simplify the equality check by removing the OR condition. This is simpler but possibly too strict for the address book domain i.e., increases the risk of duplicate entries for the same person creeping into the address book We decided to go with the alternative 2 because, * It is important to keep the code base simple, to reduce the initial learning curve of the students at the start of their project * Students can introduce a more sophisticated equality check that matches their product domain later. Also, let's change the default name in PersonBuilder utility class. This is because AddCommandIntegrationTest populates its model using getTypicalPersons() which contains a person with the default name. This test then creates another person using the default name, to be added into the model, which is expected to pass. However, the above update in equality causes this test to fail. Thus we need to change the default name to a unique name that is not inside getTypicalPersons(). Also, the default email is changed for consistency in naming the default values, it does not affect current test cases. --- .../java/seedu/address/model/person/Person.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index e3eb497b6c8..8ff1d83fe89 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -22,19 +22,17 @@ public class Person { // Data fields private final Address address; - private final Remark remark; private final Set tags = new HashSet<>(); /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, Address address, Remark remark, Set tags) { + public Person(Name name, Phone phone, Email email, Address address, Set tags) { requireAllNonNull(name, phone, email, address, tags); this.name = name; this.phone = phone; this.email = email; this.address = address; - this.remark = remark; this.tags.addAll(tags); } @@ -54,10 +52,6 @@ public Address getAddress() { return address; } - public Remark getRemark() { - return remark; - } - /** * Returns an immutable tag set, which throws {@code UnsupportedOperationException} * if modification is attempted. @@ -116,10 +110,7 @@ public String toString() { .append("; Email: ") .append(getEmail()) .append("; Address: ") - .append(getAddress()) - .append(" Remark: ") - .append(getRemark()); - + .append(getAddress()); Set tags = getTags(); if (!tags.isEmpty()) {