You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/DeveloperGuide.md
+34-31Lines changed: 34 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,7 +141,7 @@ Structure of Delivery Object
141
141
142
142
The `Storage` component,
143
143
* can save `UserPref` objects in json format and read it back.
144
-
* can save the inventory book data and delivery book in json format and read it back.
144
+
* can save the inventoryBook/deliveryBook data in json format and read it back.
145
145
146
146
### Common classes
147
147
@@ -164,6 +164,7 @@ method call to return `commandHistory`'s 2nd last command instead of the last co
164
164
With `addToHistory(String command)`, `previousCommand()`, `nextCommand()` and `currentCommand()` implemented, a simple `setOnKeyPressed` under `CommandBox` class which checks
165
165
for user's input of arrow up (which calls previousCommand()) and arrow down (which calls nextCommand()) would suffice for GUI implementation.
166
166
167
+
167
168
### Finding Items and Delivery
168
169
OneShelf is capable of storing many items and deliveries. Therefore, there is an utmost importance to have the ability to be able to find item and delivery based on different fields. There could also be many similar item and this will definitely benefit the user to find it quickly. <br>
169
170
@@ -183,41 +184,44 @@ Below is a sequence diagram of the above
Each `Model` internally stores its undo and redo history as a (for `DeliveryModel`) `deliveryBookStateList` and `deliveryBookStatePointer`. There are corresponding analogs for `InventoryModel`.
191
+
Additionally, the following commands are implemented by `ModelsManager`.
189
192
190
-
The proposed undo/redo mechanism is facilitated by `VersionedAddressBook`. It extends `AddressBook` with an undo/redo history, stored internally as an `addressBookStateList` and `currentStatePointer`. Additionally, it implements the following operations:
193
+
*`ModelsManager#commit()` — Saves the current book states of all the `Model`s it contains in their history.
194
+
*`ModelsManager#undo()` — Restores the previous book states from each `Model` from their history.
195
+
*`ModelsManager#redo()` — Restores all previously undone book states from every `Model`'s history.
191
196
192
-
*`VersionedAddressBook#commit()` — Saves the current address book state in its history.
193
-
*`VersionedAddressBook#undo()` — Restores the previous address book state from its history.
194
-
*`VersionedAddressBook#redo()` — Restores a previously undone address book state from its history.
197
+
These operations are exposed in the `Models` interface as `Models#commit()`, `Models#undo()` and `Models#redo()` respectively.
195
198
196
-
These operations are exposed in the `Model` interface as`Model#commitAddressBook()`, `Model#undoAddressBook()` and `Model#redoAddressBook()` respectively.
199
+
The `ModelsManager` class calls`Model#commit()`, `Model#undo()`, and `Model#redo` on each of the models it contains, which then handle the respective tasks.
197
200
198
201
Given below is an example usage scenario and how the undo/redo mechanism behaves at each step.
199
202
200
-
Step 1. The user launches the application for the first time. The `VersionedAddressBook` will be initialized with the initial address book state, and the `currentStatePointer` pointing to that single address book state.
203
+
Step 1. The user launches the application for the first time. Each `Model` will be initialized with its initial state, and the pointer pointing to their respective book's state.
201
204
202
205

203
206
204
-
Step 2. The user executes `delete 5` command to delete the 5th item in the address book. The `delete` command calls `Model#commitAddressBook()`, causing the modified state of the address book after the `delete 5` command executes to be saved in the `addressBookStateList`, and the `currentStatePointer` is shifted to the newly inserted address book state.
207
+
Step 2. The user executes `delete-i 5` command to delete the 5th item in the inventory book. The `delete-i` command calls `Models#commit()`, causing the modified state of the inventory and delivery books after the `delete-i 5` command executes to be saved in the `inventoryBookStateList`, `deliveryBookStateList`,
208
+
and the `inventoryBookStatePointer`, `deliveryBookStatePointer` are shifted to the newly inserted books state.
205
209
206
210

207
211
208
-
Step 3. The user executes `add n/David …` to add a new item. The `add` command also calls `Model#commitAddressBook()`, causing another modified address book state to be saved into the `addressBookStateList`.
212
+
Step 3. The user executes `add-d n/David p/12345678 …` to add a new Delivery. The `add-d` command also calls `Models#commit()`, causing another set of modified book states to be saved into the `inventoryBookStateList` and `deliveryBookStateList`.
209
213
210
214

211
215
212
-
<divmarkdown="span"class="alert alert-info">:information_source: **Note:** If a command fails its execution, it will not call `Model#commitAddressBook()`, so the address book state will not be saved into the `addressBookStateList`.
216
+
<divmarkdown="span"class="alert alert-info">:information_source: **Note:** If a command fails its execution, it will not call `Models#commit()`, so the states will not be saved into the `inventoryBookStateList` and `deliveryBookStateList`.
213
217
214
218
</div>
215
219
216
-
Step 4. The user now decides that adding the item was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoAddressBook()`, which will shift the `currentStatePointer`once to the left, pointing it to the previous address book state, and restores the address book to that state.
220
+
Step 4. The user now decides that adding the delivery was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Models#undo()`, which will shift the `deliveryBookStatePointer` and `inventoryBookStatePointer`once to the left, pointing it to the previous states, and restores the inventoryBook/deliveryBook to those states.
217
221
218
222

219
223
220
-
<divmarkdown="span"class="alert alert-info">:information_source: **Note:** If the `currentStatePointer` is at index 0, pointing to the initial AddressBook state, then there are no previous AddressBook states to restore. The `undo` command uses `Model#canUndoAddressBook()` to check if this is the case. If so, it will return an error to the user rather
224
+
<divmarkdown="span"class="alert alert-info">:information_source: **Note:** If the current state pointers are at index 0, pointing to the initial state, then there are no previous books states to restore. The `undo` command uses `InventoryModel#canUndo()` and `DeliveryModel#canUndo()` to check if this is the case. If so, it will return an error to the user rather
221
225
than attempting to perform the undo.
222
226
223
227
</div>
@@ -230,17 +234,17 @@ The following sequence diagram shows how the undo operation works:
230
234
231
235
</div>
232
236
233
-
The `redo` command does the opposite — it calls `Model#redoAddressBook()`, which shifts the `currentStatePointer`once to the right, pointing to the previously undone state, and restores the address book to that state.
237
+
The `redo` command does the opposite — it calls `Models#redo()`, which shifts the `inventoryBookStatePointer` and `deliveryBookStatePointer`once to the right, pointing to the previously undone state, and restores the inventoryBook and deliveryBook to that state.
234
238
235
-
<divmarkdown="span"class="alert alert-info">:information_source: **Note:** If the `currentStatePointer` is at index `addressBookStateList.size() - 1`, pointing to the latest address book state, then there are no undone AddressBook states to restore. The `redo` command uses `Model#canRedoAddressBook()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the redo.
239
+
<divmarkdown="span"class="alert alert-info">:information_source: **Note:** If the current pointers are pointing to the latest state, then there are no undone InventoryBook/DeliveryBook states to restore. The `redo` command uses `InventoryModel#canRedo()` and `DeliveryModel#canRedo()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the redo.
236
240
237
241
</div>
238
242
239
-
Step 5. The user then decides to execute the command `list`. Commands that do not modify the address book, such as `list`, will usually not call `Model#commitAddressBook()`, `Model#undoAddressBook()` or `Model#redoAddressBook()`. Thus, the `addressBookStateList` remains unchanged.
243
+
Step 5. The user then decides to execute the command `list-i`. Commands that do not modify the inventoryBook and deliveryBook, such as `list-d` and `find-i`, will usually not call `Models#commit()`, `Models#undo()` or `Models#redo()`. Thus, the `inventoryBookStateList` and `deliveryBookStateList` remain unchanged.
240
244
241
245

242
246
243
-
Step 6. The user executes `clear`, which calls `Model#commitAddressBook()`. Since the `currentStatePointer` is not pointing at the end of the `addressBookStateList`, all address book states after the `currentStatePointer`will be purged. Reason: It no longer makes sense to redo the `add n/David …` command. This is the behavior that most modern desktop applications follow.
247
+
Step 6. The user executes `clear-d`, which calls `Models#commit()`. Since the state pointers are not pointing at the end of the respective state lists, all states after the current state will be purged. Reason: It no longer makes sense to redo the `add-d n/David p/12345678 …` command. This is the behavior that most modern desktop applications follow.
244
248
245
249

246
250
@@ -252,7 +256,7 @@ The following activity diagram summarizes what happens when a user executes a ne
252
256
253
257
##### Aspect: How undo & redo executes
254
258
255
-
***Alternative 1 (current choice):** Saves the entire address book.
259
+
***Alternative 1 (current choice):** Saves the entire state.
256
260
* Pros: Easy to implement.
257
261
* Cons: May have performance issues in terms of memory usage.
258
262
@@ -420,18 +424,17 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
420
424
1. Should work on any _mainstream OS_ as long as it has Java `11` or above installed.
421
425
2. Should be able to hold up to 1000 items without a noticeable sluggishness in performance for typical usage.
422
426
3. 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.
423
-
4. Project should not cost any money
424
-
5. Should work on 32-bit and 64-bit environments
425
-
6. Should not take up more than 50 MB of disk space
426
-
7. Should not take up more than 250 MB of RAM
427
-
8. Commands should receive a response within 1 second
428
-
9. The system is not required to change the physical inventory
429
-
10. The system should operate within a local network
430
-
11. The data should be secured using a password
431
-
12. Users should be able to get fluent with the syntax by their 10th usage
432
-
13. The system should not provide functionality that breaks and local laws within a country it is distributed to
433
-
14. The system should still be able to function without connection to a network
434
-
15. The system should only be used by one user
427
+
4. Should work on 32-bit and 64-bit environments.
428
+
5. Should not take up more than 50 MB of disk space.
429
+
6. Should not take up more than 250 MB of RAM.
430
+
7. Add, Delete, List, Undo, Redo, Edit, and Remove Commands should receive a response within 1 second regardless of data size.
431
+
8. All other commands should receive a response withing 5 seconds regardless of data size.
432
+
9. The data should be secured using a password.
433
+
10. Users should be able to get fluent with the syntax by their 10th usage.
434
+
11. The system should still be able to function without connection to a network.
435
+
12. The system should only be used by one user.
436
+
13. Storing 100 states of the models for the Undo and Redo Commands should not take more than 100 KB.
437
+
14. Storing 100 states of history of commands the user has entered should not take more than 10 KB.
Undoes the previous command by reverting the current data displayed to the state it was in before the last command was executed.
210
+
211
+
Format: `undo`
212
+
213
+
* If there is a previous state available, the current state is reverted to that state
214
+
* If the current state is the earliest possible one, it shows a message informing the user that there is nothing more to undo
215
+
216
+
217
+
### Redo last command : `redo`
218
+
219
+
Redoes the last undone command by reverting the current data displayed to the state it was in before the last undo command was executed.
220
+
221
+
Format: `redo`
222
+
223
+
* If there is an undone state available, the current state is reverted to that state
224
+
* If the current state is the latest possible one, it shows a message informing the user that there is nothing more to redo
225
+
* After any command that changes the state of data (such as add, clear, delete, edit), the new state becomes the latest state
226
+
(i.e. the previous undo commands are "forgotten" and `redo` will have no effect)
227
+
199
228
200
229
### Saving the data
201
230
@@ -205,11 +234,6 @@ OneShelf data are saved in the hard disk automatically after any command that ch
205
234
206
235
OneShelf commands are traversable much like Window's command prompt with the arrow up key traversing into previous commands and arrow down key traversing into next commands.
207
236
208
-
### Undo `[Coming Soon]`
209
-
210
-
Undo previous command
211
-
212
-
213
237
214
238
### Sorting items`[Coming Soon]`
215
239
@@ -254,7 +278,14 @@ Notify the user if a certain stock is below threshold
0 commit comments