Skip to content

Commit

Permalink
Merge pull request #117 from TianYong-Goh/branch-DG-UG
Browse files Browse the repository at this point in the history
Update DG and UG
  • Loading branch information
TianYong-Goh authored Oct 20, 2020
2 parents 809abd6 + 3e0fbb8 commit 93f0d85
Show file tree
Hide file tree
Showing 14 changed files with 342 additions and 18 deletions.
96 changes: 95 additions & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Given below is the Sequence Diagram for interactions within the `Logic` componen
The `Model`,

* stores a `UserPref` object that represents the user’s preferences.
* stores the address book data.
* stores the wishful shrinking data.
* exposes an unmodifiable `ObservableList<Recipe>` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.
* does not depend on any of the other three components.

Expand Down Expand Up @@ -149,6 +149,100 @@ The following sequence diagram shows how the undo operation works:
#### Design consideration:
* Workflow must be consistent with other adding commands e.g add ingredients, consumption.

### Eat recipe feature

Eat Recipe feature is used to record the user daily consumption. This feature will work with list consumption
feature to output the total calories' user ate .

#### Implementation
Substitutability is used in Command and Parser:
* `EatRecipeCommand` extends `Command`
* `EatRecipeCommandParser` implements `Parser<EatRecipeCommand>`

Given bellow is the simplified step on how eat recipe is done:

Step 1:

User input is change into command.
![EatRecipeStep1](images/EatRecipeStep1.png)

Step 2:

Execute the command (make a copy of recipe from recipeList).
![EatRecipeStep2](images/EatRecipeStep2.png)

Step 3:

Add the copy recipe into consumptionList.
![EatRecipeStep3](images/EatRecipeStep3.png)


The following sequence diagram shows how eat recipe operation works when `execute(eatR 1)` API call:

![EatRecipeSequenceDiagram](images/EatRecipeSequenceDiagram.png)
<div markdown="span" class="alert alert-info">:information_source:
**Note:** The lifeline for `EatRecipeCommandParser` should end at the destroy marker (X) but due to a limitation of
PlantUML, the lifeline reaches the end of diagram.
</div>

1. `LogicManager` receive user input and undergoes logic operation for output.
1. `LogicManager` will pass the input to `WishfulShrinkingParser`.
1. `WishfulShrinkingParser` create `EatRecipeCommandParser` to parse and validate the user input.
1. `EatRecipeCommandParser` create `EatRecipeCommand` with successfully parsed input.
1. `LogicManager` execute `EatRecipeCommand`.
1. `EatRecipeCommand` get the list of recipe.
1. Get related recipe detail using the user input.
1. Pass the recipe to `Model` which responsible in adding it to consumption list.
1. `EatRecipeCommand` return a `CommandResult` back to `LogicManager`.

<div markdown="span" class="alert alert-info">:information_source:
**Note:** Delete a recipe in recipeList would not affect the consumptionList
</div>

#### Design consideration:
##### Aspect 1: Concern while adding a new feature
* Workflow must be consistent with other adding commands e.g. add recipe and ingredient.
##### Aspect 2: What are the informations to extract from a recipe and save in consumptionList
* **Alternative 1 (current choice):** Saves all the informations in recipe.
* Pros: Easy to implement.
* Cons: May have performance issues in terms of memory usage.

* **Alternative 2:** Saves the recipe's data that going to use while listing consumption.
* Pros: Will use less memory (only the information being used is copied into consumptionList).
* Cons: Not future proof (need to restructure the whole command if wanted to show more information from the recipe)

### List Consumption feature

List Consumption feature is used to list out all the recipes that user ate. This feature will also calculate
the total calories.

#### Implementation
Substitutability is used in Command and Parser:
* `ListConsumptionCommand` extends `Command`

The following sequence diagram shows how eat recipe operation works when `execute(calories)` API call:

![ListConsumptionSequenceDiagram](images/ListConsumptionSequenceDiagram.png)

1. `LogicManager` receive user input and undergoes logic operation for output.
1. `LogicManager` will pass the input to `WishfulShrinkingParser`.
1. `WishfulShrinkingParser` create `ListConsumptionCommandParser` to parse and validate the user input.
1. `LogicManager` execute `ListConsumptionCommand`.
1. `ListConsumptionCommand` get the consumption list.
1. `ListConsumptionCommand` return a `CommandResult` back to `LogicManager`.

#### Design consideration:
##### Aspect 1: Concern while adding a new feature
* Workflow must be consistent with other adding commands e.g. list recipe and ingredient.
##### Aspect 2: What are the informations to list from a recipe in consumption list
* **Alternative 1 (current choice):** Listing recipe with name and calories.
* Pros: Cleaner UI.
* Cons: Other details that is not used become an extra data in memory.

* **Alternative 2:** Listing the whole recipe's information.
* Pros: All the data saved are being used.
* Cons: Showing too much unimportant information.

### \[Proposed\] Data archiving

_{Explain here how the data archiving feature will be implemented}_
Expand Down
52 changes: 36 additions & 16 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Wishful Shrinking is a **desktop app for managing your diet, keeping track of yo

* **`recipe`** : Lists all recipes.

* **`addR`**` n/salad i/lettuce, carrots, olive oil` : Adds a `salad` recipe to Wishful Shrinking.
* **`addR`**` n/salad i/lettuce, carrots, olive oil c/40` : Adds a `salad` recipe to Wishful Shrinking.

* **`deleteR`**`3` : Deletes the 3rd recipe shown in the current list.

Expand All @@ -44,7 +44,16 @@ Wishful Shrinking is a **desktop app for managing your diet, keeping track of yo
**:information_source: Notes about the command format:**<br>

* Words in `UPPER_CASE` are the parameters to be supplied by the user.<br>
e.g. in `add n/TITLE`, `TITLE` is a parameter which can be used as `addR n/salad`.
e.g. in `add n/NAME`, `NAME` is a parameter which can be used as `addR n/salad`.

* Items in square brackets are optional.<br>
e.g `n/NAME [t/TAG]` can be used as `n/Salad t/healthy` or as `n/Salad`.

* Items with ``​ after them can be used more than 1 times.<br>
e.g. `[t/TAG]…​` can be used as `t/healthy`, `t/healthy t/low calories` etc.

* Parameters can be in any order.<br>
e.g. if the command specifies `n/NAME i/INGREDIENTS`, `i/INGREDIENTS n/NAME` is also acceptable.
</div>

### Viewing help : `help`
Expand All @@ -63,25 +72,28 @@ Format: `exit`

## Recipe

### Adding a recipe: `add`
### Adding a recipe: `addR`

Adds a recipe to Recipes Collection.

Format: `addR n/TITLE i/INGREDIENTS`
Format: `addR n/TITLE i/INGREDIENT[, MORE INGREDIENT] c/CALORIES img/IMAGE inst/INSTRUCTION... [t/TAG]...`

* `INGREDIENT` can take in an optional `Quantity` e.g. i/Tomato -2 whole
* there is a compulsory space before `-`

Examples:
* `addR n/salad i/lettuce, carrots, olive oil`
* `addR n/sandwiches i/breads, cheese`
* `addR n/salad i/lettuce, tomato, olive oil c/40`
* `addR n/sandwiches i/breads, cheese -2 sclices c/80`


### Listing all recipes : `list`
### Listing all recipes : `recipes`

Shows a list of all recipes in the Recipes Collection.

Format: `recipe`
Format: `recipes`


### Deleting a recipe : `delete`
### Deleting a recipe : `deleteR`

Deletes the specified recipe from Recipes Collection.

Expand Down Expand Up @@ -135,14 +147,14 @@ Examples:
* `addF i/banana, green peas, salmon fish`


### Listing all ingredients : `list`
### Listing all ingredients : `fridge`

Shows a list of all ingredients in the fridge.

Format: `fridge`


### Deleting an ingredient : `delete`
### Deleting an ingredient : `deleteF`

Deletes the specified ingredient from Fridge.

Expand Down Expand Up @@ -173,7 +185,7 @@ Examples:

## Consumption

### Eating a recipe : `add`
### Eating a recipe : `eatR`

Add the specified recipe to the Consumption Collection from Recipes Collection.

Expand All @@ -188,6 +200,13 @@ Examples:
* `searchR n/salad` followed by `eatR 1` deletes the 1st recipe in the results of the `search` command.


### Listing all recipes eaten : `calories`

Shows a list of all recipes eat by the user.

Format: `calories`


### Deleting a recipe eaten: `deleteC`

Deletes the specified recipe from consumption list.
Expand All @@ -207,7 +226,7 @@ Examples:
Wishful Shrinking data are saved in the hard disk automatically after any command that changes the data. There is no need to save manually.


### Remark `[coming in v1.3]`
### Remark `[coming in v1.4]`

_{give a remark to the recipe}_

Expand All @@ -228,15 +247,16 @@ _{give a remark to the recipe}_

Features | Format, Examples
--------|------------------
**Add recipe** | `addR n/TITLE i/INGREDIENTS` <br> e.g., `addR n/salad i/lettuce, carrots, olive oil`
**Add recipe** | `addR n/TITLE i/INGREDIENT[, MORE INGREDIENT] c/CALORIES img/IMAGE inst/INSTRUCTION... [t/TAG]...` <br> e.g., `addR n/salad i/lettuce, carrots, olive oil c/80`
**Add Ingredient to the fridge** | `addF i/INGREDIENTS` <br> e.g., `addF i/banana, green peas, salmon fish`
**Delete recipe** | `deleteR INDEX`<br> e.g., `deleteR 3`
**Delete Ingredient from the fridge** | `deleteF INDEX`<br> e.g., `deleteF 3`
**Delete recipe eaten**| `deleteC INDEX` <br> e.g., `deleteC 3`
**Search recipe** | `searchR i/INGREDIENT` OR `searchR n/TITLE` OR `searchR t/TAG` <br> e.g., `searchR i/lettuce` `searchR n/salad` `searchR t/healthy`
**Search recipe** | `searchR i/INGREDIENT` OR `searchR n/TITLE` OR `searchR t/TAG` <br> e.g. `searchR i/lettuce`, `searchR n/salad`, `searchR t/healthy`
**Search Ingredient in the fridge** | `searchF KEYWORD`<br> e.g., `searchF avocado`
**List recipe** | `recipe`
**List recipe** | `recipeS`
**List ingredients in the fridge** | `fridge`
**List recipes eaten** | `calories`
**Recommend recipe** | `recommend`
**Eat recipe**| `eatR INDEX` <br> e.g., `eatR 3`
**Help** | `help`
Expand Down
92 changes: 92 additions & 0 deletions docs/diagrams/EatRecipeSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
@startuml
!include style.puml

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":WishfulShrinkingParser" as WishfulShrinkingParser LOGIC_COLOR
participant ":EatRecipeCommandParser" as EatRecipeCommandParser LOGIC_COLOR
participant "command :EatRecipeCommand" as EatRecipeCommand 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("eatR 1")
activate LogicManager

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

create EatRecipeCommandParser
WishfulShrinkingParser -> EatRecipeCommandParser
activate EatRecipeCommandParser

EatRecipeCommandParser --> WishfulShrinkingParser
deactivate EatRecipeCommandParser

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

create EatRecipeCommand
EatRecipeCommandParser -> EatRecipeCommand
activate EatRecipeCommand

EatRecipeCommand --> EatRecipeCommandParser
deactivate EatRecipeCommand

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

WishfulShrinkingParser --> LogicManager : command
deactivate WishfulShrinkingParser

LogicManager -> EatRecipeCommand : execute()
activate EatRecipeCommand

EatRecipeCommand -> Model : getFilteredRecipeList()
activate Model

Model --> EatRecipeCommand : List<Recipe>
deactivate Model

Model --> EatRecipeCommand
deactivate Model

EatRecipeCommand -> Model : addConsumption(1)
activate Model

Model -> WishfulShrinking : addConsumption(1)
activate WishfulShrinking

WishfulShrinking --> ConsumptionList: eat(1)
activate ConsumptionList

ConsumptionList --> WishfulShrinking
deactivate ConsumptionList

WishfulShrinking --> Model
deactivate WishfulShrinking

Model --> EatRecipeCommand
deactivate Model

create CommandResult
EatRecipeCommand -> CommandResult
activate CommandResult

CommandResult --> EatRecipeCommand
deactivate CommandResult

EatRecipeCommand --> LogicManager : result
deactivate EatRecipeCommand

[<--LogicManager
deactivate LogicManager
@enduml
20 changes: 20 additions & 0 deletions docs/diagrams/EatRecipeStep1.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@startuml
!include style.puml
skinparam ClassFontColor #000000
skinparam ClassBorderColor #000000

title Step 1

class userInput
class command

package CollectionList {
class recipeList
class consumptionList
}

recipeList -[hidden]right-> consumptionList
userInput -[hidden]up- recipeList
userInput -> command

@end
22 changes: 22 additions & 0 deletions docs/diagrams/EatRecipeStep2.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@startuml
!include style.puml
skinparam ClassFontColor #000000
skinparam ClassBorderColor #000000

title Step 2

class userInput
class command
class recipe

package CollectionList {
class recipeList
class consumptionList
}

recipeList -[hidden]right-> consumptionList
userInput -> command
command -[hidden]right> recipe
recipeList -down-> recipe

@end
Loading

0 comments on commit 93f0d85

Please sign in to comment.