Skip to content

Commit

Permalink
Merge branch 'master' into documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
daongochieu2810 authored Oct 20, 2020
2 parents a580a61 + 6afc30f commit 20e3e8d
Show file tree
Hide file tree
Showing 44 changed files with 1,030 additions and 50 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ checkstyle {
toolVersion = '8.29'
}

run {
enableAssertions = true
}

test {
useJUnitPlatform()
finalizedBy jacocoTestReport
Expand Down
132 changes: 132 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,138 @@ The following sequence diagram shows how eat recipe operation works when `execut
##### Aspect 1: Concern while adding a new feature
* Workflow must be consistent with other listing commands e.g. fridge and calories.

### Add Ingredient feature

#### Implementation
This feature allows users to add ingredients into the fridge.

Substitutability is used in Command and Parser:
* `AddIngredientCommand` extends `Command`
* `AddIngredientCommandParser` implements `Parser<AddIngredientCommand>`

Given below is an example usage scenario and how the mechanism behaves at each step.

![AddIngredientSequence](images/AddIngredientSequence.png)

Step 1:
User inputs the add ingredient command to add ingredients into the fridge.

Step 2:
After successful parsing of user input, the `AddIngredientCommand#execute(Model model)` method is called.

Step 3:
The ingredients that the user has input will be saved into Wishful Shrinking's fridge of ingredients.

Step 4:
After the successful adding of the ingredient, a `CommandResult` object is instantiated and returned to `LogicManager`.

#### Design Considerations
##### Aspect 1: Concern while adding a new feature
* Workflow must be consistent with other adding commands e.g. add recipe and eat recipe for consumption.

##### Aspect 2: How do we successfully parse the ingredients the user has added with the optional ingredient quantity
* **Alternative 1 (current choice):** Add a quantity field in the Ingredient class as well as a IngredientParser class that parses the user ingredients that the user has input into an arraylist of Ingredient objects
* Pros: Easy to implement.
* Cons: The parser may confuse ingredients that have prefixes that Wishful Shrinking uses to identify fields in the names, eg "-" or ","

### Search Recipe feature

#### Implementation
This feature allows users search for recipes in the recipe list based on the name, tags or ingredients.

Substitutability is used in Command and Parser:
* `SearchRecipeCommand` extends `Command`
* `SearchRecipeCommandParser` implements `Parser<SearchRecipeCommand>`

Given below is an example usage scenario and how the mechanism behaves at each step.

![SearchRecipeSequence](images/SearchRecipeSequence.png)

Step 1:
User inputs the search recipe command to search for the recipes they want.

Step 2:
After successful parsing of user input, the `SearchRecipeCommand#execute(Model model)` method is called.

Step 3:
The list of recipes that fit the user's search will be returned to the user.

Step 4:
After the successful searching of the recipes, a `CommandResult` object is instantiated and returned to `LogicManager`.

#### Design Considerations
##### Aspect 1: Concern while adding a new feature
* Workflow must be consistent with other searching commands e.g. search recipe.

##### Aspect 2: How do we successfully search and filter the recipes based on the user' search
* **Alternative 1 (current choice):** User can only search for recipes based on one fields at a time
* Pros: Easy to implement.
* Cons: User's cannot filter the recipes by two or three fields at once

* **Alternative 2:** User can only search for recipes by all fields at once
* Pros: Harder to implement.
* Cons: User's can filter the recipes by two or three fields at once

### Delete Consumption feature

#### Implementation
This feature allows users to delete the recipes they have eaten in the calorie tracker.

Substitutability is used in Command and Parser:
* `DeleteConsumptionCommand` extends `Command`
* `DeleteConsumptionCommandParser` implements `Parser<DeleteConsumptionCommand>`

Given below is an example usage scenario and how the mechanism behaves at each step.

![DeleteConsumptionSequence](images/DeleteConsumptionSequence.png)

Step 1:
User inputs the delete consumption command to delete the recipes eaten in the calorie tracker.

Step 2:
After successful parsing of user input, the `DeleteConsumptionCommand#execute(Model model)` method is called.

Step 3:
The recipe that the user has specified will be deleted from the consumption list.

Step 4:
After the successful deleting of recipes, a `CommandResult` object is instantiated and returned to `LogicManager`.

#### Design Considerations
##### Aspect 1: Concern while adding a new feature
* Workflow must be consistent with other deleting commands e.g. delete recipe and delete ingredient.

### Recommend feature

#### Implementation
This feature allows users to get recommended recipes that they are able to make with the ingredients in their fridge.

Substitutability is used in Command:
* `RecommendCommand` extends `Command`

Given below is an example usage scenario and how the mechanism behaves at each step.

![RecommendSequence](images/RecommendSequence.png)

Step 1:
User inputs the recommend command to get the recommended recipes.

Step 2:
After successful parsing of user input, the `RecommendCommand#execute(Model model)` method is called.

Step 3:
The list of recommended recipes will be returned to the user.

Step 4:
After the successful recommending of recipes, a `CommandResult` object is instantiated and returned to `LogicManager`.

#### Design Considerations
##### Aspect : How do we quickly and accurately compare ingredients in each recipe and the user's fridge
* **Alternative 1 (current choice):** Compare the exact ingredients in each recipe to the users ingredients in the fridge
* Pros: Easy to implement
* Cons: Slow to compare, the ingredients might not match if the spellings are different, or if the ingredient has similar names, eg mozarella and cheese. Other than that, if users do not input basic ingredients into their fridge, eg salt and pepper, the recipe might not get recommended to them.


--------------------------------------------------------------------------------------------------------------------

## **Documentation, logging, testing, configuration, dev-ops**
Expand Down
89 changes: 89 additions & 0 deletions docs/diagrams/AddIngredientSequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
@startuml
!include style.puml

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":WishfulShrinkingParser" as WishfulShrinkingParser LOGIC_COLOR
participant ":AddIngredientCommandParser" as AddIngredientCommandParser LOGIC_COLOR
participant "command :AddIngredientCommand" as AddIngredientCommand LOGIC_COLOR
participant ":CommandResult" as CommandResult LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
participant ":WishfulShrinking" as WishfulShrinking MODEL_COLOR
participant ":UniqueIngredientList" as UniqueIngredientList MODEL_COLOR
end box

[-> LogicManager : execute("addF i/tomato")
activate LogicManager

LogicManager -> WishfulShrinkingParser : parseCommand("addF i/tomato")
activate WishfulShrinkingParser

create AddIngredientCommandParser
WishfulShrinkingParser -> AddIngredientCommandParser
activate AddIngredientCommandParser

AddIngredientCommandParser --> WishfulShrinkingParser
deactivate AddIngredientCommandParser

WishfulShrinkingParser -> AddIngredientCommandParser : parse("i/tomato")
activate AddIngredientCommandParser

create AddIngredientCommand
AddIngredientCommandParser -> AddIngredientCommand
activate AddIngredientCommand

AddIngredientCommand --> AddIngredientCommandParser : command
deactivate AddIngredientCommand

AddIngredientCommandParser --> WishfulShrinkingParser : command
deactivate AddIngredientCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
AddIngredientCommandParser -[hidden]-> WishfulShrinkingParser
destroy AddIngredientCommandParser

WishfulShrinkingParser --> LogicManager : command
deactivate WishfulShrinkingParser

LogicManager -> AddIngredientCommand : execute()
activate AddIngredientCommand

AddIngredientCommand -> Model : updateFilteredIngredientList(predicate)
activate Model

Model --> AddIngredientCommand
deactivate Model

AddIngredientCommand -> Model : addIngredient("tomato")
activate Model

Model -> WishfulShrinking : addIngredient("tomato")
activate WishfulShrinking

WishfulShrinking --> UniqueIngredientList: add("tomato")
activate UniqueIngredientList

UniqueIngredientList --> WishfulShrinking
deactivate UniqueIngredientList

WishfulShrinking --> Model
deactivate WishfulShrinking

Model --> AddIngredientCommand
deactivate Model

create CommandResult
AddIngredientCommand -> CommandResult
activate CommandResult

CommandResult --> AddIngredientCommand
deactivate CommandResult

AddIngredientCommand --> LogicManager : result
deactivate AddIngredientCommand

[<--LogicManager
deactivate LogicManager
@enduml
89 changes: 89 additions & 0 deletions docs/diagrams/DeleteConsumptionSequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
@startuml
!include style.puml

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":WishfulShrinkingParser" as WishfulShrinkingParser LOGIC_COLOR
participant ":DeleteConsumptionCommandParser" as DeleteConsumptionCommandParser LOGIC_COLOR
participant "d:DeleteConsumptionCommand" as DeleteConsumptionCommand LOGIC_COLOR
participant ":CommandResult" as CommandResult LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
participant ":WishfulShrinking" as WishfulShrinking MODEL_COLOR
participant ":ConsumptionList" as ConsumptionList MODEL_COLOR
end box

[-> LogicManager : execute("deleteC 1")
activate LogicManager

LogicManager -> WishfulShrinkingParser : parseCommand("deleteC 1")
activate WishfulShrinkingParser

create DeleteConsumptionCommandParser
WishfulShrinkingParser -> DeleteConsumptionCommandParser
activate DeleteConsumptionCommandParser

DeleteConsumptionCommandParser --> WishfulShrinkingParser
deactivate DeleteConsumptionCommandParser

WishfulShrinkingParser -> DeleteConsumptionCommandParser : parse("1")
activate DeleteConsumptionCommandParser

create DeleteConsumptionCommand
DeleteConsumptionCommandParser -> DeleteConsumptionCommand
activate DeleteConsumptionCommand

DeleteConsumptionCommand --> DeleteConsumptionCommandParser : command
deactivate DeleteConsumptionCommand

DeleteConsumptionCommandParser --> WishfulShrinkingParser : command
deactivate DeleteConsumptionCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
DeleteConsumptionCommandParser -[hidden]-> WishfulShrinkingParser
destroy DeleteConsumptionCommandParser

WishfulShrinkingParser --> LogicManager : command
deactivate WishfulShrinkingParser

LogicManager -> DeleteConsumptionCommand : execute()
activate DeleteConsumptionCommand

DeleteConsumptionCommand -> Model : getFilteredConsumptionList()
activate Model

Model --> DeleteConsumptionCommand
deactivate Model

DeleteConsumptionCommand -> Model : deleteConsumption(target)
activate Model

Model -> WishfulShrinking : removeConsumption(key)
activate WishfulShrinking

WishfulShrinking --> ConsumptionList: remove(toRemove)
activate ConsumptionList

ConsumptionList --> WishfulShrinking
deactivate ConsumptionList

WishfulShrinking --> Model
deactivate WishfulShrinking

Model --> DeleteConsumptionCommand
deactivate Model

create CommandResult
DeleteConsumptionCommand -> CommandResult
activate CommandResult

CommandResult --> DeleteConsumptionCommand
deactivate CommandResult

DeleteConsumptionCommand --> LogicManager : result
deactivate DeleteConsumptionCommand

[<--LogicManager
deactivate LogicManager
@enduml
58 changes: 58 additions & 0 deletions docs/diagrams/RecommendSequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@startuml
!include style.puml

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":WishfulShrinkingParser" as WishfulShrinkingParser LOGIC_COLOR
participant "command :RecommendCommand" as RecommendCommand LOGIC_COLOR
participant ":CommandResult" as CommandResult LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
end box

[-> LogicManager : execute(recommend)
activate LogicManager

LogicManager -> WishfulShrinkingParser : parseCommand(recommend)
activate WishfulShrinkingParser

create RecommendCommand
WishfulShrinkingParser -> RecommendCommand
activate RecommendCommand

RecommendCommand --> WishfulShrinkingParser : command
deactivate RecommendCommand

WishfulShrinkingParser --> LogicManager : command
deactivate WishfulShrinkingParser

LogicManager -> RecommendCommand : execute()
activate RecommendCommand

RecommendCommand -> Model : updateFilteredRecipeList(predicate)
activate Model

Model --> RecommendCommand
deactivate Model

RecommendCommand -> Model : getFilteredRecipeList()
activate Model

Model --> RecommendCommand
deactivate Model

create CommandResult
RecommendCommand -> CommandResult
activate CommandResult

CommandResult --> RecommendCommand
deactivate CommandResult

RecommendCommand --> LogicManager : result
deactivate RecommendCommand

[<--LogicManager
deactivate LogicManager
@enduml
Loading

0 comments on commit 20e3e8d

Please sign in to comment.