Skip to content

Commit

Permalink
Merge pull request #120 from jiaqi20/documentation
Browse files Browse the repository at this point in the history
Update DG
  • Loading branch information
daongochieu2810 authored Oct 20, 2020
2 parents 6afc30f + 20e3e8d commit 809abd6
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 0 deletions.
58 changes: 58 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,64 @@ The following sequence diagram shows how the undo operation works:

_{Explain here how the data archiving feature will be implemented}_

### Delete recipe feature

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

Substitutability is used in Command and Parser:
* `DeleteRecipeCommand` extends `Command`
* `DeleteRecipeCommandParser` implements `Parser<DeleteRecipeCommand>`

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

Step 1:
User inputs the delete recipe command to delete recipe from the recipe list.

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

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

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

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

![DeleteRecipeSequence](images/DeleteRecipeSequence.png)

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

### List Recipe Feature

#### Implementation
This feature allows user to list out all the recipes that was saved.

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

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

Step 1:
User inputs the list recipe command to show all recipes from the recipe list.

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

Step 3:
After successfully generating a list of recipes, a `CommandResult` object is instantiated and returned to `LogicManager`.

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

![ListRecipeSequence](images/ListRecipesSequence.png)

#### Design consideration:
##### 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
Expand Down
86 changes: 86 additions & 0 deletions docs/diagrams/DeleteRecipeSequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
@startuml
!include style.puml

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":WishfulShrinkingParser" as WishfulShrinkingParser LOGIC_COLOR
participant ":DeleteRecipeCommandParser" as DeleteRecipeCommandParser LOGIC_COLOR
participant "d:DeleteRecipeCommand" as DeleteRecipeCommand 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 ":UniqueRecipeList" as UniqueRecipeList MODEL_COLOR
end box

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

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

create DeleteRecipeCommandParser
WishfulShrinkingParser -> DeleteRecipeCommandParser
activate DeleteRecipeCommandParser

DeleteRecipeCommandParser --> WishfulShrinkingParser
deactivate DeleteRecipeCommandParser

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

create DeleteRecipeCommand
DeleteRecipeCommandParser -> DeleteRecipeCommand
activate DeleteRecipeCommand

DeleteRecipeCommand --> DeleteRecipeCommandParser : command
deactivate DeleteRecipeCommand

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

WishfulShrinkingParser --> LogicManager : command
deactivate WishfulShrinkingParser

LogicManager -> DeleteRecipeCommand : execute()
activate DeleteRecipeCommand

DeleteCommand -> Model : getFilteredRecipeList()
activate Model

Model -> WishfulShrinking : removeRecipe(key)
activate WishfulShrinking

WishfulShrinking -> UniqueRecipeList : remove(toRemove)
activate UniqueRecipeList

UniqueRecipeList -> WishfulShrinking
deactivate UniqueRecipeList

WishfulShrinking -> Model
deactivate WishfulShrinking

Model -> DeleteRecipeCommand
deactivate Model

Model --> DeleteRecipeCommand
deactivate Model

create CommandResult
DeleteRecipeCommand -> CommandResult
activate CommandResult

CommandResult --> DeleteRecipeCommand
deactivate CommandResult

DeleteRecipeCommand --> LogicManager : result
deactivate DeleteRecipeCommand

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

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":WishfulShrinkingParser" as WishfulShrinkingParser LOGIC_COLOR
participant "l:ListRecipesCommand" as ListRecipesCommand 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
end box

[-> LogicManager : execute("recipes")
activate LogicManager

LogicManager -> WishfulShrinkingParser : parseCommand("recipes")
activate WishfulShrinkingParser

create ListRecipesCommand
WishfulShrinkingParser -> ListRecipesCommand
activate ListRecipesCommand

ListRecipesCommand --> WishfulShrinkingParser
deactivate ListRecipesCommand

WishfulShrinkingParser --> LogicManager : command
deactivate WishfulShrinkingParser

LogicManager -> ListRecipesCommand : execute()
activate ListRecipesCommand

ListRecipesCommand -> Model : updateFilteredRecipeList()
activate Model

Model -> WishfulShrinking : getRecipeList()
activate WishfulShrinking

WishfulShrinking -> UniqueRecipeList : asUnmodifiableObservableList()
activate UniqueRecipeList

UniqueRecipeList -> WishfulShrinking
deactivate UniqueRecipeList

WishfulShrinking -> Model
deactivate WishfulShrinking

Model -> ListRecipesCommand
deactivate Model

Model --> ListRRecipesCommand
deactivate Model

create CommandResult
ListRecipesCommand -> CommandResult
activate CommandResult

CommandResult --> ListRecipesCommand
deactivate CommandResult

ListRecipesCommand --> LogicManager : result
deactivate ListRecipesCommand

[<--LogicManager
deactivate LogicManager
@enduml
Binary file added docs/images/DeleteRecipeSequence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ListRecipesSequence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static java.util.Objects.requireNonNull;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
Expand All @@ -24,6 +26,8 @@ public class DeleteRecipeCommand extends Command {

public static final String MESSAGE_DELETE_RECIPE_SUCCESS = "Deleted Recipe: %1$s";

private static Logger logger = Logger.getLogger("DeleteLogger");

private final Index toDelete;

public DeleteRecipeCommand(Index toDelete) {
Expand All @@ -32,6 +36,7 @@ public DeleteRecipeCommand(Index toDelete) {

@Override
public CommandResult execute(Model model) throws CommandException {
logger.log(Level.INFO, "going to start deleting");
requireNonNull(model);
List<Recipe> lastShownList = model.getFilteredRecipeList();

Expand All @@ -41,6 +46,7 @@ public CommandResult execute(Model model) throws CommandException {

Recipe recipeToDelete = lastShownList.get(toDelete.getZeroBased());
model.deleteRecipe(recipeToDelete);
logger.log(Level.INFO, "end of deleting");
return new CommandResult(String.format(MESSAGE_DELETE_RECIPE_SUCCESS, recipeToDelete));
}

Expand Down

0 comments on commit 809abd6

Please sign in to comment.