You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/DeveloperGuide.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -173,6 +173,34 @@ The following activity diagram summarizes what happens when a user executes a bl
173
173
* Pros: Able to directly set blacklist status without checking current status.
174
174
* Cons: More commands to remember.
175
175
176
+
### Find persons by tag feature
177
+
This feature is built on the current `find` command, which is used to be limited to only finding persons by names. With this change, the format of the `find` command is now modified to `find n/[NAME] t/[TAG]`.
178
+
This command returns the persons with attributes that matches at least one of the attributes of interest (See User Guide for more details).
179
+
Note that users are only required to provide at least one of the parameters to use this command. In other words, commands such as `find n/Alex` and `find t/autistic` are valid commands.
180
+
181
+
To facilitate the implementation of this feature, two new predicate classes are introduced, namely `PersonTagContainsKeywordsPredicate` and `ReturnTruePredicate`. The former class is to check whether any of the `tag`s contain the keywords. The latter predicate always returns `true`.
182
+
183
+
The introduction of `ReturnTruePredicate` may seem pointless, but it is of great use. The key here is to realize that if X is a boolean variable, then X `and``true` simplifies to X. If both `name` and `tag` keywords are given, the `FindCommand` class will receive `NameContainsKeywordsPredicate` and `PersonTagContainsKeywordsPredicate`. If, say, only `name` keywords are given, then `ReturnTruePredicate` will instead be supplied to `FindCommand`.
184
+
As such, the filter will now solely depend on `NameContainsKeywordsPredicate` since the second predicate always returns true.
185
+
186
+
The following sequence diagram shows how the `find` command works:
***Alternative 1 (current choice):**`find` command alone supports finding by names and tags.
197
+
* Pros: More intuitive to use since most commands have similar format. Makes further extensions easier as developers only need to define a new predicate class.
198
+
* Cons: Can make debugging harder since further extensions are centralized into one class.
199
+
200
+
***Alternative 2:** Find by names and find by tags are separate commands.
201
+
* Pros: Easier to debug as one command is meant for one criterion.
202
+
* Cons: It is now not possible to combine both criteria together. More commands to remember. Due to similarity of the commands, they can be confused from one another.
0 commit comments