Skip to content

Commit

Permalink
Merge branch 'master' into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
qiujiaaa committed Nov 11, 2019
2 parents 425594e + e632a7c commit f03bbc9
Show file tree
Hide file tree
Showing 47 changed files with 263 additions and 174 deletions.
106 changes: 82 additions & 24 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ The `Storage` component,
[[Design-Commons]]
=== Common classes

Classes used by multiple components are in the `seedu.addressbook.commons` package.
Classes used by multiple components are in the `seedu.address.commons` package.

== Implementation

Expand Down Expand Up @@ -584,15 +584,15 @@ The undo/redo mechanism is facilitated by `UndoRedoStack`.
`UndoableCommand` extends Command and has the following attributes and methods.


image::dg-diagram/UndoableCommandClassDiagram.png[]
image::dg-diagram/UndoableCommandClassDiagram.png[width="300"]

When an UndoableCommand is being executed, the methods `saveCustomerBookSnapshot(Model model)`, `savePhoneBookSnapshot(Model model)`, `saveOrderBookSnapshot(Model model)`, `saveScheduleBookSnapshot(Model model)`
and `saveArchivedOrderBookSnapshot(Model model)` will be called. This ensures that the states of all 5 books are being stored.

After a command is executed, `LogicManager` will add it into the `UndoRedoStack`.
This will be explained in the activity diagram below.

image::dg-diagram/UndoRedoStackPushActivityDiagram.png[]
image::dg-diagram/UndoRedoStackPushActivityDiagram.png[width="600"]

Next, when `UndoCommand` is being performed, `UndoStack` will remove the first command in its stack and add it to `RedoStack`.
It will then call `UndoableCommand#undo()` of the command that is removed.
Expand All @@ -608,42 +608,43 @@ Given below is an example usage scenario and how the undo/redo mechanism behaves




Step 1. The user launches the application for the first time. The `UndoRedoStack` will be initialized.

image::dg-diagram/UndoRedoStackObjectDiagram0.png[]
image::dg-diagram/UndoRedoStackObjectDiagram0.png[[width="450"]

Step 2. The user executes `delete-c 5` command to delete the 5th customer. The `delete-c 5` command will be pushed into the `UndoRedoStack`.

image::dg-diagram/UndoRedoStackObjectDiagram1.png[]
image::dg-diagram/UndoRedoStackObjectDiagram1.png[[width="450"]

Step 3. The user executes `add-c n/David ...` to add a new person. The `add-c` command will save all states of CustomerBook, PhoneBook, OrderBook, ScheduleBook and ArchivedOrderBook.
Step 3. The user executes `add-c n/David ...` to add a new customer. The `add-c` command will save all states of CustomerBook, PhoneBook, OrderBook, ScheduleBook and ArchivedOrderBook.

image::dg-diagram/UndoRedoStackObjectDiagram2.png[]
image::dg-diagram/UndoRedoStackObjectDiagram2.png[[width="450"]

Step 4. The user now decides that adding the customer was a mistake, and decides to undo that action by executing the `undo` command.


image::dg-diagram/UndoRedoStackObjectDiagram3.png[]
image::dg-diagram/UndoRedoStackObjectDiagram3.png[[width="450"]

[NOTE]
UndoCommand will check whether if there is any command to be undone by calling the `UndoRedoStack#canUndo()` method.

The following sequence diagram shows how the undo operation works:

image::dg-diagram/UndoSequenceDiagram.png[]
image::dg-diagram/UndoSequenceDiagram.png[[width="450"]

NOTE: The lifeline for `UndoCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

NOTE: XYZ here refers to Customer, Phone, Order, Schedule and ArchivedOrder.

The `redo` command does the opposite -- it calls `UndoableCommand#redo()`.

Step 5. The user then decides to execute the command `list-c`. Commands that do not modify the 5 books (Customer, Phone, Order, Schedule and Archived Order), such as `list-c`, do not extend UndoableCommand.

image::dg-diagram/UndoRedoStackObjectDiagram4.png[]
image::dg-diagram/UndoRedoStackObjectDiagram4.png[[width="450"]

Step 6. The user executes `clear-c`.

image::dg-diagram/UndoRedoStackObjectDiagram5.png[]
image::dg-diagram/UndoRedoStackObjectDiagram5.png[[width="450"]

==== Design Considerations

Expand All @@ -655,6 +656,7 @@ image::dg-diagram/UndoRedoStackObjectDiagram5.png[]
* **Alternative 2:** Individual command knows how to undo/redo by itself.
** Pros: Will use less memory (e.g. for `delete-c`, just save the customer being deleted).
** Cons: We must ensure that the implementation of each individual command are correct.
// end::undoredo[]

===== Aspect: Data structure to support the undo/redo commands

Expand All @@ -664,7 +666,7 @@ image::dg-diagram/UndoRedoStackObjectDiagram5.png[]
* **Alternative 2:** Use `HistoryManager` for undo/redo
** Pros: We do not need to maintain a separate list, and just reuse what is already in the codebase.
** Cons: Requires dealing with commands that have already been undone: We must remember to skip these commands. Violates Single Responsibility Principle and Separation of Concerns as `HistoryManager` now needs to do two different things.
// end::undoredo[]


// tag::dataencryption[]
=== [Proposed] Data Encryption
Expand Down Expand Up @@ -730,8 +732,6 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un
|Priority |As a ... |I want to ... |So that I can...
|`* * *` |new user |see usage instructions |refer to instructions when I forget how to use the App

|`* * *` |user |add a new person |

|`* * *` |handphone seller |schedule my orders| deconflict and view the schedule of my sales meetings.

|`* *` |handphone seller |generate an invoice |give my customers the invoice.
Expand Down Expand Up @@ -908,7 +908,7 @@ Use case resumes at step 1.
== Non Functional Requirements

. Should work on any <<mainstream-os,mainstream OS>> as long as it has Java `11` or above installed.
. Should be able to hold up to 1000 persons without a noticeable sluggishness in performance for typical usage.
. Should be able to hold up to 1000 customers/phones/orders without a noticeable sluggishness in performance for typical usage.
. A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse.
. Single User for each session
. No internet required
Expand All @@ -922,17 +922,75 @@ _ {More to be added}_
[appendix]
== Glossary

[[mainstream-os]] Mainstream OS::

[[mainstream-os]] Mainstream OS::
Windows, Linux, Unix, OS-X

[[private-contact-detail]] Private contact detail::
A contact detail that is not meant to be shared with others
. *SML* +
Initialism for our application, Seller Manager Lite.

. *Customer* +
A person who buys from the seller.

. *Phone* +
Multi-purpose mobile computing device. Also known as smartphones.

. *Order* +
A request for goods.

. *Schedule* +
A meetup with buyer to pass the goods. There can only be 1 schedule associated with an order at any one time.

=== SML-specific Terms

. *Command* +
An instruction that will produce an output once entered in SML.

. *CustomerBook* +
A CustomerBook is a list that stores Customer(s) that has been added into SML.
Each customer entry comprises of CustomerName, ContactNumber and Email fields and others.

. *PhoneBook* +
A PhoneBook is a list that stores Phone(s) that has been added in SML.
Each phone entry comprises of IdentityNumber, SerialNumber, Brand, PhoneName, Colour, Cost and Capacity.

. *OrderBook* +
A OrderBook is a list that stores Order(s) that has been added in SML.
Each order entry comprises of a customer, a phone, OrderID, Price and OrderStatus.

. *ScheduleBook* +
A ScheduleBook is a list that stores Schedules(s) that has been added in SML.
Each schedule entry comprises a Venue and Calendar with date and time.

. *Archived* +
Archived is a list that stores Completed or Cancelled orders ONLY.

. *TabPanel* +
A view that is similar to web browser Tabs.

. *Add* +
The action of putting an entry into CustomerBook, PhoneBook, OrderBook or ScheduleBook.

. *Edit* +
If you want to make changes to any entry, you can do so with this command.

. *Delete* +
Remove an entry from CustomerBook, PhoneBook or ScheduleBook.

. *Find* +
The action of searching for customers, phones or orders that contains the keywords that you specify.

. *Switch* +
Change the Tab Panel to Customer, Phone, Order, Schedule or Archived.

. *Undo* +
If you've made a mistake, you can simply revert to the previous command.

[[order]] Order::
A order consisting of customer and phone
. *Redo* +
Inverse of undo.

[[Phone]] Phone::
Any mobile device being sold by seller
. *Copy* +
Action of copying an entry into clipboard.

[appendix]
== Product Survey
Expand Down Expand Up @@ -986,7 +1044,7 @@ These instructions only provide a starting point for testers to work on; testers

=== Deleting a customer

. Deleting a customer while all persons are listed
. Deleting a customer while all customers are listed

.. Prerequisites: List all customers using the `list-c` command. Multiple customers in the list.
.. Test case: `delete-c 1` +
Expand Down
28 changes: 18 additions & 10 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Customers cannot share the same contact number or email.
* Adds a single customer
. `add-c n/Steve Jobs c/12345678 e/[email protected]`

image::ug-command/ug-add-c.png[width="900"]
image::ug-command/ug-add-c.png[width="600"]

==== Delete a customer : `delete-c`
Deletes a customer in SML. Note that deleting a customer will also delete the orders and schedules associated with the customer. +
Expand Down Expand Up @@ -269,13 +269,13 @@ Finds customers whose fields contain any of the given keywords. +
* Find customers with keyword `colleague` +
. `find-c colleague` +

image::ug-command/ug-find-c-1.png[width="800"]
image::ug-command/ug-find-c-1.png[width="600"]

* Find customers with keywords `charlotte` `oliveiro` +
. `find-c charlotte oliveiro` +

image::ug-command/ug-find-c-2.png[width="800"]

image::ug-command/ug-find-c-2.png[width="600"]
// end::customer[]

==== List the customers : `list-c`

Expand Down Expand Up @@ -341,7 +341,7 @@ Emails a customer in SML. Opens Gmail on web browser and drafts an email to cust
[underline]#Format#: `email-c INDEX`


// end::customer[]


// tag::phone[]
=== Phone Commands
Expand Down Expand Up @@ -728,6 +728,9 @@ image::ug-command/ug-undo.png[width="800"]
==== Redo : `redo`
Redo the previous undone command. Inverse of undo. +

When you redo a delete command, it will specifically delete the customer/phone/order that was previously deleted.
When you redo an add command, it will specifically add the customer/phone/order that was previously added.

Currently, the following commands are undoable and redoable. +

. Add Customer
Expand All @@ -739,6 +742,7 @@ Currently, the following commands are undoable and redoable. +
. Edit Order
. Complete Order
. Cancel Order
. Clear Order

. Add Phone
. Edit Phone
Expand Down Expand Up @@ -784,7 +788,7 @@ image::ug-command/ug-redo.png[width="800"]

=== History: `history`

Views the command history of all your previous commands.
Views the command history of all your previous commands, starting from the latest to the earliest command.

[underline]#Format#: `history`

Expand Down Expand Up @@ -1038,7 +1042,7 @@ The hash tag represents the length of the valid input for the primary key.

==== Add fields to a new product `[coming in v2.0]`

This command is to allow users to add a field to their product.
This command allow users to add a field to their product.
Users have to first key in the field name.
This will be followed by the data type of the field.
The data types that will be supported are: #_DIGIT, #_CHARACTERS, #_ALPHANUMERIC, and also any of the existing fields.
Expand All @@ -1047,6 +1051,10 @@ The hash tag represents the length of the valid input for the primary key.

[underline]#Format#: `addfield PRODUCT_NAME FIELD_NAME DATA_TYPE `

=== Autocorrect `[coming in v2.0]`

Corrects any typos that you may have while typing the commands.

== FAQ
*Q*: How do I transfer my data to another Computer? +
*A*: Install the app in the other computer and overwrite the empty data file it creates with the file that contains the data of your previous SML folder.
Expand All @@ -1061,12 +1069,12 @@ The hash tag represents the length of the valid input for the primary key.
|=======================================================================
|Command | Summary
|`switch-c` | Switches to customer tab panel.
|`add-c n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]…`| Adds a new customer into SML
|`edit-c INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [t/TAG]…​ `| Edits an existing customer.
|`add-c n/NAME p/PHONE_NUMBER e/EMAIL [t/TAG]…`| Adds a new customer into SML
|`edit-c INDEX [n/NAME] [p/PHONE] [e/EMAIL] [t/TAG]…​ `| Edits an existing customer.
|`delete-c INDEX`| Deletes a customer and its associated orders and schedules.
|`clear-c`| Deletes all customers and their associated orders and schedules.
|`find-c KEYWORD [MORE_KEYWORDS]`| Finds the customers that contains the keywords in its field.
|`copy-c INDEX`| Copies a customer into clipboard
|`copy-c INDEX`| Copies a customer into clipboard.
|=======================================================================


Expand Down
19 changes: 19 additions & 0 deletions docs/diagrams/UndoSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ UndoableCommand --> UndoStack : toUndoCommand

deactivate UndoableCommand



UndoStack --> UndoRedoStack : toUndoCommand

deactivate UndoStack
Expand All @@ -69,13 +71,30 @@ UndoableCommand -> Model : setXYZBook, updateFilteredXYZList
activate Model


deactivate Model

Model --> UndoableCommand

UndoableCommand --> UndoCommand
deactivate UndoableCommand

UndoCommand -> UndoableCommand : save()
activate UndoableCommand

UndoableCommand -> UndoableCommand ++: saveXYZBookSnapshot()

UndoableCommand -> Model : getXYZBook()
activate Model

Model --> UndoableCommand : XYZBook
deactivate Model

UndoableCommand --> UndoCommand
deactivate UndoableCommand




UndoCommand --> LogicManager : result
deactivate UndoCommand
UndoCommand -[hidden]-> LogicManager : result
Expand Down
28 changes: 14 additions & 14 deletions docs/diagrams/UndoableCommandClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ abstract class Command {

abstract class UndoableCommand {

- ReadOnlyDataBook<Customer> previousCustomerBook
- ReadOnlyDataBook<Order> previousOrderBook
- ReadOnlyDataBook<Phone> previousPhoneBook
- ReadOnlyDataBook<Schedule> previousScheduleBook
- ReadOnlyDataBook<Order> previousArchivedOrderBook
- previousCustomerBook
- previousOrderBook
- previousPhoneBook
- previousScheduleBook
- previousArchivedOrderBook

- void saveCustomerBookSnapshot(Model model)
- void saveOrderBookSnapshot(Model model)
- void savePhoneBookSnapshot(Model model)
- void saveScheduleBookSnapshot(Model model)
- void saveArchivedOrderBookSnapshot(Model model)
- saveCustomerBookSnapshot(Model model)
- saveOrderBookSnapshot(Model model)
- savePhoneBookSnapshot(Model model)
- saveScheduleBookSnapshot(Model model)
- saveArchivedOrderBookSnapshot(Model model)

# final void undo(Model model)
# final void redo(Model model)
# undo(Model model)
# redo(Model model)


+ void save(Model model)
+ CommandResult execute(Model model, CommandHistory commandHistory,
+ execute(Model model, CommandHistory commandHistory,
UndoRedoStack undoRedoStack)



# CommandResult executeUndoableCommand(Model model, CommandHistory commandHistory,
# executeUndoableCommand(Model model, CommandHistory commandHistory,
UndoRedoStack undoRedoStack) {abstract}

}
Expand Down
Binary file removed docs/images/UndoRedoState0.png
Binary file not shown.
Binary file removed docs/images/UndoRedoState1.png
Binary file not shown.
Binary file removed docs/images/UndoRedoState2.png
Binary file not shown.
Binary file removed docs/images/UndoRedoState3.png
Binary file not shown.
Binary file removed docs/images/UndoRedoState4.png
Binary file not shown.
Binary file removed docs/images/UndoRedoState5.png
Binary file not shown.
Binary file removed docs/images/UndoSequenceDiagram.png
Binary file not shown.
Binary file modified docs/images/dg-diagram/UndoSequenceDiagram.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/dg-diagram/UndoableCommandClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f03bbc9

Please sign in to comment.