Skip to content

Commit 79b4f39

Browse files
authored
Merge pull request #52 from JQChong/update-find-doc
Update find doc
2 parents 5f0ee80 + dc8f323 commit 79b4f39

5 files changed

Lines changed: 105 additions & 0 deletions

File tree

docs/DeveloperGuide.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,34 @@ The following activity diagram summarizes what happens when a user executes a bl
173173
* Pros: Able to directly set blacklist status without checking current status.
174174
* Cons: More commands to remember.
175175

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:
187+
![FindSequenceDiagram](images/FindSequenceDiagram.png)
188+
189+
The following activity diagram shows what happens when `find` command is executed.
190+
![FindActivityDiagram](images/FindActivityDiagram.png)
191+
192+
#### Design considerations:
193+
194+
##### Aspect: Command design
195+
196+
* **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.
203+
176204
### \[Proposed\] Undo/redo feature
177205

178206
#### Proposed Implementation
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@startuml
2+
start
3+
:User executes find command;
4+
repeat
5+
:Check if the next person matches the keywords;
6+
repeat while () is ([has next person])
7+
-> [else];
8+
:Display results;
9+
end
10+
@enduml
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
@startuml
2+
!include style.puml
3+
4+
box Logic LOGIC_COLOR_T1
5+
participant ":LogicManager" as LogicManager LOGIC_COLOR
6+
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
7+
participant ":FindCommandParser" as FindCommandParser LOGIC_COLOR
8+
participant ":FindCommand" as FindCommand LOGIC_COLOR
9+
participant ":CommandResult" as CommandResult LOGIC_COLOR
10+
end box
11+
12+
box Model MODEL_COLOR_T1
13+
participant ":Model" as Model MODEL_COLOR_T1
14+
end box
15+
16+
[-> LogicManager : execute("find n/Alex t/friends")
17+
activate LogicManager
18+
19+
LogicManager -> AddressBookParser : parseCommand("find n/Alex t/friends")
20+
activate AddressBookParser
21+
22+
create FindCommandParser
23+
AddressBookParser -> FindCommandParser
24+
activate FindCommandParser
25+
26+
FindCommandParser --> AddressBookParser
27+
deactivate FindCommandParser
28+
29+
AddressBookParser -> FindCommandParser : parse("n/Alex t/friends")
30+
activate FindCommandParser
31+
32+
create FindCommand
33+
FindCommandParser -> FindCommand
34+
deactivate FindCommand
35+
36+
FindCommand --> FindCommandParser
37+
deactivate FindCommand
38+
39+
FindCommandParser --> AddressBookParser
40+
deactivate AddressBookParser
41+
42+
AddressBookParser --> LogicManager
43+
deactivate AddressBookParser
44+
45+
LogicManager -> FindCommand : execute()
46+
activate FindCommand
47+
48+
FindCommand -> Model : updateFilteredPersonList
49+
activate Model
50+
51+
Model --> FindCommand
52+
deactivate Model
53+
54+
create CommandResult
55+
FindCommand -> CommandResult
56+
activate CommandResult
57+
58+
CommandResult --> FindCommand
59+
deactivate CommandResult
60+
61+
FindCommand --> LogicManager : result
62+
deactivate FindCommand
63+
64+
[<--LogicManager
65+
deactivate LogicManager
66+
67+
@enduml
14 KB
Loading
29.3 KB
Loading

0 commit comments

Comments
 (0)