Skip to content

Commit

Permalink
Update Developer Guide
Browse files Browse the repository at this point in the history
  • Loading branch information
cutieprobe committed Nov 6, 2019
1 parent 80704a0 commit 4fd650a
Show file tree
Hide file tree
Showing 19 changed files with 205 additions and 22 deletions.
22 changes: 22 additions & 0 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -585,15 +585,37 @@ replace the current command word/argument in user input.
==== Current Implementation
The command suggestions is achieved using a package of prompter files.
For each parser, there will a corresponding prompter to process the current user input and return the `CommandPrompt` for display in `ResultBox`.
The following class diagram summarizes the Prompter package in the Logic.

.Partial Class Diagram of the Logic Component related Prompter package
image::CommandPromptClassDiagram.png[]

The following Sequence Diagram summarizes the how a `CommandPrompt` is generated:

image::CommandPromptSequenceDiagram.png[]

Here is how a user interact with the command suggestion features:

Step 1. The user types commands into the `CommandBox`.

Step 2. The `MainWindow` listens to changes in the content in `CommandBox` and direct the input to `WemePrompter`.

Step 3. Depending on the context, the prompter that implements `WemePrompter` (e.g. `MemePrompter`) will then pass the arguments

to different `Prompter` (e.g. `MemeAddCommandPrompter`) based on the command word.

Step 4: The `Prompter` will process the input and return a `CommandPrompt` containing the command suggestion, and the

complete text for auto-completion for the given input.

Step 5: The prompt will be passed to and displayed by `ResultBox`.

Step 6: The `CommandBox` listens to the "TAB" key press, and replace the current argument with the first command prompt.

The following Activity Diagram summarizes the how the command suggestion process:

image::CommandPromptActivityDiagram.png[]

==== Design Considerations

===== Aspect: How to process the input and produce the command prompt
Expand Down
22 changes: 22 additions & 0 deletions docs/diagrams/CommandPromptActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@startuml
start
:User types in a partial command;

'Since the beta syntax does not support placing the condition outside the
'diamond we place it as the true branch instead.

if () then ([The command format is invalid])
:Error messaged shown;
else ([Else])
if () then ([Input is a word but\n not command word])
:Similar command\n words is displayed;
else if () then ([Input is a command word])
:Command usage\n is displayed;
else ([Input is multiple words])
:Suggestions for command\n argument is displayed;
endif
endif
:User presses TAB key;
:Command suggestion is auto-completed by replacing the input;
stop
@enduml
42 changes: 42 additions & 0 deletions docs/diagrams/CommandPromptClassDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@startuml
!include style.puml
skinparam arrowThickness 1.1
skinparam arrowColor LOGIC_COLOR_T4
skinparam classBackgroundColor LOGIC_COLOR

package Logic {

package Prompter {
Interface Prompter <<Interface>>
Class WemePrompter
Class XYZPrompter
Class XYZCommandPrompter
Class PrompterUtil
Class CommandPrompt
}
Interface Logic <<Interface>>
Class LogicManager
}

package Model{
Class HiddenModel #FFFFFF
}

Class HiddenOutside #FFFFFF
HiddenOutside ..> Logic

LogicManager .up.|> Logic
LogicManager ..> WemePrompter

XYZPrompter -up-|> WemePrompter
XYZPrompter .down.> XYZCommandPrompter : creates >
note right of XYZPrompter: XYZPrompter = MemePrompter, \nTemplatePrompter, \nImportPrompter, etc.
XYZCommandPrompter ..> CommandPrompt : creates >
note right of XYZCommandPrompter: XYZCommandPrompter = \n MemeAddCommandPrompter, \nTemplateEditCommandPrompter, \nLoadCommandPrompter, etc.
XYZCommandPrompter ..|> Prompter
XYZCommandPrompter ..> PrompterUtil
LogicManager .down.> CommandPrompt : prompt >
CommandPrompt .right.> Model

LogicManager --> Model
@enduml
63 changes: 63 additions & 0 deletions docs/diagrams/CommandPromptSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@startuml
scale 1.5
!include style.puml

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":MemePrompter" as MemePrompter LOGIC_COLOR
participant ":MemeAddCommandPrompter" as MemeAddCommandPrompter LOGIC_COLOR
participant ":PrompterUtil" as PrompterUtil LOGIC_COLOR
participant ":CommandPrompt" as CommandPrompt LOGIC_COLOR
end box

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

[-> LogicManager : execute("add p/")
activate LogicManager

LogicManager -> MemePrompter : promptCommand("add p/")
activate MemePrompter

create MemeAddCommandPrompter
MemePrompter -> MemeAddCommandPrompter
activate MemeAddCommandPrompter

MemeAddCommandPrompter --> MemePrompter
deactivate MemeAddCommandPrompter

MemePrompter -> MemeAddCommandPrompter : prompt("p/")
activate MemeAddCommandPrompter

MemeAddCommandPrompter -> PrompterUtil : promptSimilarArguments("p/")
activate PrompterUtil

PrompterUtil -> Model : getRecords()
activate Model

Model --> PrompterUtil : records
deactivate Model

create CommandPrompt
PrompterUtil -> CommandPrompt
activate CommandPrompt

CommandPrompt --> PrompterUtil
deactivate CommandPrompt

PrompterUtil --> MemeAddCommandPrompter : commandPrompt
deactivate PrompterUtil

MemeAddCommandPrompter --> MemePrompter : commandPrompt
deactivate MemeAddCommandPrompter
'Hidden arrow to position the destroy marker below the end of the activation bar.
MemeAddCommandPrompter -[hidden]-> MemePrompter
destroy MemeAddCommandPrompter

MemePrompter --> LogicManager : commandPrompt
deactivate MemePrompter

[<--LogicManager : commandPrompt
deactivate LogicManager
@enduml
18 changes: 18 additions & 0 deletions docs/diagrams/LogicClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ Class ArgumentTokenizer
Class Prefix
}

package Prompter {
Interface Prompter <<Interface>>
Class WemePrompter
Class XYZPrompter
Class XYZCommandPrompter
Class PrompterUtil
Class CommandPrompt
}

package Command {
Class XYZCommand
Class CommandResult
Expand All @@ -37,6 +46,7 @@ HiddenOutside ..> Logic

LogicManager .up.|> Logic
LogicManager ..> WemeParser
LogicManager ..> WemePrompter

XYZParser -up-|> WemeParser
XYZParser .down.> XYZCommandParser : creates >
Expand All @@ -55,6 +65,14 @@ ArgumentTokenizer .down.> Prefix
XYZCommand -up-|> Command
LogicManager .left.> Command : executes >

XYZPrompter -up-|> WemePrompter
XYZPrompter .down.> XYZCommandPrompter : creates >
note right of XYZPrompter: XYZPrompter = MemePrompter, TemplatePrompter, \nImportPrompter, etc.
XYZCommandPrompter ..> CommandPrompt : creates >
XYZCommandPrompter ..|> Prompter
XYZCommandPrompter ..> PrompterUtil
LogicManager .down.> CommandPrompt : prompt >

LogicManager --> Model
Command .right.> Model
note right of XYZCommand: XYZCommand = MemeAddCommand, \nFindCommand, etc
Expand Down
9 changes: 9 additions & 0 deletions docs/diagrams/ModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Interface ReadOnlyWeme <<Interface>>
Interface Model <<Interface>>
Interface ObservableList <<Interface>>
Interface Stats <<Interface>>
Interface Records <<Interface>>
Class Weme
Class ReadOnlyWeme
Class Model
Expand Down Expand Up @@ -37,6 +38,10 @@ Class LikeManager
Class TagManager
}

Package Record {
Class RecordsManager
}

Package Tag {
Class Tag
}
Expand Down Expand Up @@ -65,6 +70,8 @@ Meme *--> "*" Tag

Weme *-right-> "1" StatsManager

Weme *-right-> "1" RecordsManager

Weme *--> "1" UniqueTemplateList
UniqueTemplateList o--> "*" Template
Template *--> "1" Name
Expand All @@ -76,6 +83,8 @@ StatsManager *--> "1" TagManager
LikeManager *--> "1" LikeData
LikeManager *--> "1" DislikeData

RecordsManager .up.|> Records

ModelManager -->"1" Meme : filtered list
ModelManager -->"1" Template : filtered list
@enduml
Binary file added docs/images/CommandPromptActivityDiagram.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/CommandPromptClassDiagram.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/CommandPromptSequenceDiagram.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 modified docs/images/LogicClassDiagram.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 modified docs/images/ModelClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/java/seedu/weme/model/ReadOnlyWeme.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import javafx.collections.ObservableMap;
import seedu.weme.model.meme.Meme;
import seedu.weme.model.records.Records;
import seedu.weme.model.statistics.Stats;
import seedu.weme.model.statistics.TagWithCount;
import seedu.weme.model.statistics.TagWithDislike;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/weme/model/Weme.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import seedu.weme.model.meme.Description;
import seedu.weme.model.meme.Meme;
import seedu.weme.model.meme.UniqueMemeList;
import seedu.weme.model.records.Records;
import seedu.weme.model.records.RecordsManager;
import seedu.weme.model.statistics.Stats;
import seedu.weme.model.statistics.StatsManager;
import seedu.weme.model.statistics.TagWithCount;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.weme.model;
package seedu.weme.model.records;

import java.awt.Color;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.weme.model;
package seedu.weme.model.records;

import static java.util.Objects.requireNonNull;

Expand Down
36 changes: 18 additions & 18 deletions src/main/java/seedu/weme/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import seedu.weme.commons.util.FileUtil;
import seedu.weme.model.ReadOnlyUserPrefs;
import seedu.weme.model.ReadOnlyWeme;
import seedu.weme.model.Records;
import seedu.weme.model.RecordsManager;
import seedu.weme.model.Weme;
import seedu.weme.model.imagePath.ImagePath;
import seedu.weme.model.meme.Description;
import seedu.weme.model.meme.Meme;
import seedu.weme.model.records.Records;
import seedu.weme.model.records.RecordsManager;
import seedu.weme.model.tag.Tag;
import seedu.weme.model.template.Name;
import seedu.weme.model.template.Template;
Expand All @@ -32,29 +32,29 @@ public class SampleDataUtil {
public static List<Meme> getSampleMemes(ReadOnlyUserPrefs userPrefs) {
// sample memes from resources folder
List<MemeFieldsContainer> memeFields = List.of(
new MemeFieldsContainer("memes/5642dc30-927c-4e02-805d-831ea16bc68e.png",
"A meme about doge.", "doge", "cute"), // doge
new MemeFieldsContainer("memes/74b9fc9f-a545-4bbc-98d5-09596a9166a9.jpg",
"A meme about Char and charmander.", "charmander", "cute"), // charmander
new MemeFieldsContainer("memes/8de6b9f5-32a5-4eab-aebe-f47c2257e7d5.png",
"A meme about joker.", "joker"), // joker
new MemeFieldsContainer("memes/ab6e1ed6-6025-4e84-b5da-8555ef1e0b05.png",
"A meme about toy.", "toy", "funny"), // toy
new MemeFieldsContainer("memes/b3afd215-8746-4113-aa19-1747d3578f41.jpg",
"A meme about a test.", "test", "funny") // test
new MemeFieldsContainer("memes/5642dc30-927c-4e02-805d-831ea16bc68e.png",
"A meme about doge.", "doge", "cute"), // doge
new MemeFieldsContainer("memes/74b9fc9f-a545-4bbc-98d5-09596a9166a9.jpg",
"A meme about Char and charmander.", "charmander", "cute"), // charmander
new MemeFieldsContainer("memes/8de6b9f5-32a5-4eab-aebe-f47c2257e7d5.png",
"A meme about joker.", "joker"), // joker
new MemeFieldsContainer("memes/ab6e1ed6-6025-4e84-b5da-8555ef1e0b05.png",
"A meme about toy.", "toy", "funny"), // toy
new MemeFieldsContainer("memes/b3afd215-8746-4113-aa19-1747d3578f41.jpg",
"A meme about a test.", "test", "funny") // test
);
return createSampleMemes(memeFields, userPrefs);
}

public static List<Template> getSampleTemplates(ReadOnlyUserPrefs userPrefs) {
// sample templates from resources folder
List<TemplateFieldsContainer> templateFields = List.of(
new TemplateFieldsContainer("Drake Reaction",
"templates/e2493713-6904-4530-98d1-eedc7fd88e5d.jpg"),
new TemplateFieldsContainer("Is This",
"templates/0b4cc6ed-85b5-4ca0-a6b2-95ba5d29d06a.jpg"),
new TemplateFieldsContainer("Quiz Kid",
"templates/51460170-ef3e-41ad-8243-d0890e838cff.jpg")
new TemplateFieldsContainer("Drake Reaction",
"templates/e2493713-6904-4530-98d1-eedc7fd88e5d.jpg"),
new TemplateFieldsContainer("Is This",
"templates/0b4cc6ed-85b5-4ca0-a6b2-95ba5d29d06a.jpg"),
new TemplateFieldsContainer("Quiz Kid",
"templates/51460170-ef3e-41ad-8243-d0890e838cff.jpg")
);
return createSampleTemplates(templateFields, userPrefs);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/weme/storage/JsonSerializableRecords.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import com.fasterxml.jackson.annotation.JsonRootName;

import seedu.weme.commons.exceptions.IllegalValueException;
import seedu.weme.model.Records;
import seedu.weme.model.RecordsManager;
import seedu.weme.model.records.Records;
import seedu.weme.model.records.RecordsManager;

/**
* An Immutable Records that is serializable to JSON format.
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/seedu/weme/model/ModelManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import seedu.weme.commons.core.GuiSettings;
import seedu.weme.model.meme.TagContainsKeywordsPredicate;
import seedu.weme.model.records.Records;
import seedu.weme.model.records.RecordsManager;
import seedu.weme.model.statistics.Stats;
import seedu.weme.model.statistics.StatsManager;
import seedu.weme.testutil.WemeBuilder;
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/seedu/weme/model/WemeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import seedu.weme.model.meme.Meme;
import seedu.weme.model.meme.exceptions.DuplicateMemeException;
import seedu.weme.model.records.Records;
import seedu.weme.model.records.RecordsManager;
import seedu.weme.model.statistics.Stats;
import seedu.weme.model.statistics.StatsManager;
import seedu.weme.model.statistics.TagWithCount;
Expand Down

0 comments on commit 4fd650a

Please sign in to comment.