Hi! I am Zhi Xiang, a Year 2 Computer Science student at the National University of Singapore (NUS). Below is a summary of my contributions to this project.

PROJECT: Seller Manager Lite

Overview

For our module CS2103T: Software Engineering, my team and I were tasked to enhance a desktop address book application called AddressBook.

We eventually turned it into a product called Seller Manager Lite (SML), which aims to help small-scale handphone resellers manage their sales and inventory with ease. Users interact with it using a Command Line Interface (CLI) and it has a Graphical User Interface (GUI) created with JavaFX. It is written in Java and has more than 15,000 lines of code.

My role was being in charge of the Logic component, implementing the commands and parsers for Customer, Phone and Order data. Also, I was tasked to implement undo/redo, find (search) and copy commands.

Summary of contributions

  • Major enhancement: I added the ability to undo/redo previous commands

    • What it does: allows the user to undo all previous commands one at a time. Preceding undo commands can be reversed by using the redo command.

    • Justification: This feature improves the product significantly because a user can make mistakes in commands and the app should provide a convenient way to rectify them.

    • Highlights: This enhancement affects existing commands and commands to be added in future. It required an in-depth analysis of design alternatives. The implementation too was challenging as it required changes to existing commands.

    • Credits: yamgent - I adapted some of his code to implement the UndoRedoStack and fixed the bugs that came with his approach.

  • Minor enhancement: I added the ability to create/read/update/delete customer, phone and order.

  • Minor enhancement: I added find command(s) that allows the user to search for customers, phones or orders that match certain keywords. This required enhancing the existing find command.

  • Minor enhancement: I added copy command(s) that allows the user to copy the data that they want onto their clipboard. This would make it convenient for them to copy data out of the application.

  • Code contributed:

  • contributed more than 11,000 lines of code (LoC):

  • Functional

  • Test

    • Command Tests: #168

    • Model Manager: #106

  • Other contributions:

    • Project management:

      • Managed releases v1.3.1, v1.3.2 and v1.3.4 (3 releases) on GitHub

    • Enhancements to existing features:

      • Created an Archived order tab panel (backend) as we realise that there was too much clutter in the order tab panel. #148

      • Added a history command to allow forgetful users to remember what they typed in. #154

      • Helped to implement Model Manager #75

    • Documentation:

      • Restructured User Guide to make it more reader-friendly: #168, #258

    • Community:

    • Tools:

      • Set-up Netlify

      • Set-up Codacy #123

      • Added reposense config.json file #120

Contributions to the User Guide

Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users.

Customer Commands

Commands that work on customers in SML.

Switch to Customer Tab Panel: switch-c

Switches to Customer Tab Panel.

Format: switch-c

Add a customer: add-c

Adds a Customer to the CustomerBook.
This can be done in any Tab Panel.

Format: add-c n/NAME c/CONTACT_NUMBER e/EMAIL [t/TAG]…

Contact numbers should be 8-digits long.
A customer can have any number of tags, including 0.
Customers can share the same name.
Customers cannot share the same contact number or email.

Examples:

  • Adds a single customer

    1. add-c n/Steve Jobs c/12345678 e/stevejobs@apple.com

ug add c

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.

Format: delete-c INDEX

  • Deletes the customer at the specified INDEX.

  • The index refers to the index number shown in the displayed customer list.

  • The index must be a positive integer 1, 2, 3, …​

Examples:

  • Delete the 2nd customer.

    1. list-c

    2. delete-c 2

  • Delete the 1st customer after performing a find customer command.

    1. find-c alice

    2. delete-c 1

Find a customer: find-c

Finds customers whose fields contain any of the given keywords.

Format: find KEYWORD [MORE_KEYWORDS]…​

  • The search is case insensitive. e.g hans will match Hans

  • The search matches anywhere for the name, contact number, email and tags.

  • The search looks for partial matches e.g. ha will match hans. However, hns will not match hans.

  • Entries matching ALL fields will be returned (i.e. AND search).

    • e.g. find-c aaa bbb will match a customer with name Aaah and with tag bbb

Examples:

  • Find customers with keyword colleague

    1. find-c colleague

ug find c 1
  • Find customers with keywords charlotte oliveiro

    1. find-c charlotte oliveiro

ug find c 2

Contributions to the Developer Guide

Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project.

Undo/Redo feature

Current Implementation

The undo/redo mechanism is facilitated by UndoRedoStack.

UndoRedoStack contains 2 stacks, undoStack and redoStack. undoStack and redoStack contain commands that are of type UndoableCommand. UndoableCommand extends Command and has the following attributes and methods.

UndoableCommandClassDiagram

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.

UndoRedoStackPushActivityDiagram

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. The undo() method will then set the model to the previous snapshots of CustomerBook, PhoneBook, OrderBook, ScheduleBook and ArchivedOrderBook. After which, it will save the original state of the model (e.g. before Undo took place) by calling UndoableCommand#save(Model model).

Likewise, when RedoCommand is being performed, RedoStack will remove the first command in its stack and add it to UndoStack. It will then call UndoableCommand#redo() of the command that is removed. The redo() method will then set the model to the previous snapshots of CustomerBook, PhoneBook, OrderBook, ScheduleBook and ArchivedOrderBook.

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

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

[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.

[width="450"

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.

[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.

[width="450"
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:

[width="450"
The lifeline for UndoCommand should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of the diagram.
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.

[width="450"

Step 6. The user executes clear-c.

[width="450"

Design Considerations

Aspect: How undo & redo executes
  • Alternative 1 (current choice): Saves the entire model.

    • Pros: Easy to implement.

    • Cons: May have performance issues in terms of memory usage.

  • 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 command is correct.