By: Ong Wei Sheng
, Zhu Zikun
, Qiu Yi Wen
, Li Kexuan
, Jiang Qixiong
Last Updated: 12 April 2021
easyLog is a Command Line Interface (CLI) application for home based businesses to manage items and orders in their inventory. easyLog allows users to add new items and orders, view existing items and orders, remove specific items and orders and clear all existing items and orders in the inventory at ease. If the user types fast, easyLog can get logistic management tasks done faster than traditional Graphical User Interface (GUI) applications.
easyLog, comprises a Parser component, Ui component, Storage component, Item component, Order component and Command component. Each component consists of various classes that work in tandem, to ensure it meets the purpose of our program.
The purpose of this developer guide is to allow any interested contributors who wish to develop this application further or just curious about the workings of this application. This would allow potential contributors to be able to dive right in to improving the code, performance, features or even adding new features much more easily due to the understanding of the structure of the codebase and implementation of existing features.
Fork the easyLog repository here and git clone it to any location on your computer.
Open any IDE (IntelliJ Idea preferred as mentioned in the prerequisites) and click Configure
-> Project Defaults
-> Project Structure
-> New
Next, go to Import Project
and select the build.gradle file.
After opening the project, go to src
-> main
-> java
-> seedu.easylog
-> EasyLog and right click on the
EasyLog class.
Upon successful run, the following opening message will be shown:
____________________________________________________________
Hello! I'm easyLog!
What can I do for you? Enter help to view commands.
____________________________________________________________
Looking for save data.
Save data not found.
____________________________________________________________
In this section, we discuss the various design of the different components of the application.
The EasyLog component contains the main method which is required by Java to run the application. Its main responsibility is to initialize the app and after initialization continuously ask for user’s input until the exit command is executed. More details of the EasyLog component will be explained in the future sections.
Apart from the EasyLog
component, the application also consists of the following components:
Ui
: Handles asking for user’s input and printing of feedback from user’s input.Parser
: Processes user’s input to decide what command should be executed.Command
: Executes actions related to the command.Model
: Holds data related to inputs from the user.Storage
: Handles loading, creating and saving of data into .txt
files.Common
: Contains variables and messages commonly used in all the components.The EasyLog component is responsible for initializing the app. It initializes the app by
instantiating classes from the Ui
, Parser
, Model
and Storage
components. More details regarding the
initialization will be covered in the Implementation section.
The UI component does the following:
The Parser component deals with the input of the user. It makes sense of the users input and executes respective commands according to the user’s input. This component consists of 3 different classes:
Parser
class to determine the type of feature the user wants to use. (e.g. items or orders feature)ItemsParser
class to process inputs related to items
features.OrdersParser
class to process inputs related to orders
features.All four ExitCommand, OrdersCommand, ItemsCommand and HelpCommand classes extend the abstract Command class. OrdersCommand and ItemsCommand Classes are abstract class, and it has various Command classes (e.g. OrdersXXXCommand, ItemsXXXCommand) extending them, in order to deal with different command actions ask by the user.
Parser
class new Command
object will be created.Command
class.Model
and its data (e.g. adding a new item).The model component consists of four classes, namely, Item
, ItemManager
, Order
and OrderManager
classes. Item
and Order
classes represent real-world item and order objects easyLog is tasked to keep track of. Note that the UML
diagram above omits less important details for more comprehensibility.
Item
class is used to store item attributes (i.e., item description, unit price, stock and sales). Primarily, Item
class has all necessary getter and setter methods foritemManager
to modify a particular item’s attributes when
necessary.
ItemManager
class stores the item list (the list of items existing in the inventory) and a founded item list (the
list of items found when the user gives items find
command). Primarily, ItemManager
includes methods which various
item-related commands (e.g., ItemsAddCommand
) required to perform neccesary operations to modify (e.g., add) items in
the item list.
Order
class is used to store order attributes (i.e., customer’s name, descriptions of items ordered, quantities of
items ordered and whether the order is done). Primarily, Order
class has all necessary getter and setter methods
for orderManager
to modify a particular order’s attributes when necessary.
OrderManager
class stores the order list (the list of orders placed by customers) and a founded order list (the list
of orders founded when the user gives orders find
command). Primarily, OrderManager
has methods which various
orders-related commands (e.g., OrdersAddCommand
) required to perform neccesary operations to modify (e.g., add)
orders in the orders list.
The Storage component consists of 3 different classes
Storage
class to initialize required classes for it’s subclasses.SaveData
class to deal with the loading, saving and creation of save data.Receipt
class to deal with the generation of receipts when an order is done.Logging
class to setup logging environment and allow log messages to be entered. (Not shown in storage diagram)
Logging
class is not related to the above 3 classes.The Common component consists of 2 different classes:
Constants
class to store all variables that are frequently used in the various components.Messages
class to store all the texts for the UI to print onto the command line.In this section, we explain the details and implementation of the more important features of easyLog.
As seen from the sequence diagram above, upon initialization,
EasyLog
will show the user a greeting message.As mentioned in the design of the Parser component, the Parser component handles the processing of inputs.
We will now explain the steps to how user inputs is being processed:
splitCommandWordAndArgs
method in the Parser
class. This is to
determine the type of feature that the user wants to use e.g., items
feature, orders
feature, help
feature, or the
exit
feature.processUserInput
in the Parser
class then determines the type of feature to be executed using
the command word provided by the user. If items
and orders
feature are being executed, the remaining arguments being
typed by the user is being processed using the processItemsInput
method from the ItemsParser
class or the
processOrdersInput
method using the OrdersParser
class respectively.help
command or exit
command is being inputted by the user, the processUserInput
from the Parser
class will directly call the execute
method of the relevant command.processItemsInput
and processOrdersInput
will then also use the splitCommandWordAndArgs
method to similarly
determine the type of items
and orders
features to execute e.g., items add
, orders add
, items update
etc.items
and orders
feature to execute, the execute
methods of the respective
commands will be called by either the processItemsInput
or processOrdersInput
method and the command arguments
would also be passed into the execute
method for the respective commands in order to properly execute the command
inputted by the user.As seen form the sequence diagram above (note that some trivial details are removed from the diagram), when loadFile
method in the SaveData
class is being executed,
File
object with pathname of the save file.File
object previously created.loadFile
method and show the user that no save data was found.Scanner
object using the save file.
The items add
feature is designed to allow users to add items to the system, including the item name, price and stock
of each item. As seen from the sequence diagram above (note that some trivial details are removed from the diagram),
when an item is added into the system:
itemsAddcommand
by typing items add <item_name>
.itemsParser
and calls the promptAndProcessItemPriceAndStock(String)
method to ask user the
itemPrice
and itemStock
of this item.itemPrice
and itemStock
by calling
itemPriceInStringToBigDecimalFormat(String)
and itemStockInStringToIntegerFormat(String)
methods, until the
itemPrice
and itemStock
given by the user are both valid.itemsParser
creates a new Item
object, which would be returned to itemsAddCommand
.itemsManager
and calls the addItem(Item)
method to add this item into the system.UI
sends back the confirmation message to user by calling showAddItem(Item)
method.Please note that less important details are omitted for better comprehensibility. For instance, in the first diagram of this section,
only the interactions after ItemsUpdateCommand.execute()
is modelled. In the second diagram of this section,
details of itemsPromptPriceCommand
and itemsPromptPriceCommand
are omitted.
The diagram above shows the first stage of itemsUpdateCommand
, after the user executes the itemUpdateCommand
by typing items update
and easyLog invokes itemsParser
.
ItemUpdateCommand
first gets the item size from ItemManager
.ItemUpdateCommand
calls askForItemIndex from UI
to print a message that an item index is required.ItemUpdateCommand
creates a new ItemsListCommand
object and uses ItemsListCommand.execute()
to get the item list
for the user.ItemUpdateCommand
prompts the user for input by calling askForUserInput()
from UI
.ItemUpdateCommand
gets the item size from ItemManager
again.ItemUpdateCommand
calls askForItemFieldToBeUpdated
and askForUserInput() from UI
to print a question message
and get the user input.p
or s
), start from step 7 again.Next,
ItemUpdateCommand
calls processUpdateAttributeInput
of ItemsParser
.If the user input is “p”:
ItemsParser
calls askForRevisedItemPrice
from UI
. ItemsParser
creates an object of
ItemsPromptPriceCommand
and its execute()
method is executed to ask the user for a valid revisedItemPrice
.
The details are omitted to increase comprehensibility. If the item price given is not valid, the user needs to keep
entering it until it is valid.ItemsParser
calls ItemManager
to set the revised price, getting the item of interest before calling UI
to show
it is updated correctly.If the user input is “s”, the logic is largely similar to when it is “p”. The explanations are omitted here to avoid repetition.
As seen from the sequence diagram above, when user wants to add an Order.
As seen form the sequence diagram above (note that some trivial details are removed from the diagram), when an order is deleted
The orders done
feature and generation of receipts are split into 2 parts where the first sequence diagram shows the
implementation for orders done
feature, and the second sequence diagram shows the implementation when generating a
receipt.
As seen from the sequence diagram above, when the execute
method in OrdersDoneCommand
class is executed,
OrderManager
class.As seen from the sequence diagram above, when the generateReceipt
method from the Receipt
class is called,
getCustomerName method
from the
OrderManager
class.Receipts
if the directory does not already exist in the folder that the easyLog.jar
file is being executed from using the File
class.File
class.FileWriter
object called fw
is then created to write the relevant order details into the receipt file that was
previously created in step 4.fw
object using the close
method when the order details are written finish into the receipt file.As seen from the above sequence diagram, when the execute method of the ExitCommand
class is being called,
saveFile
method from SaveData
class.saveFile
method then creates a new File
object called saveData
.saveData
object then checks if a save file previously exists, if the save file does not exists, it creates the
save file using the saveData
object.FileWriter
object called fw
is then called to write details like item details, orders details and receipt counter
into the save file.fw
object using the close
method when the order details are written finish into the save file.System.exit(0)
method.All documentation can be found under the docs/
folder. Alternatively, visit
https://ay2021s2-cs2113t-t09-4.github.io/tp/ to browse all the document.
In this section, we present different types of tests and how they can be run.
There are primarily three types of tests:
Unit tests. Tests are conducted on the fundamental level methods/classes.
e.g. seedu.easyLog.commons.ConstantsTest
Integration tests. Tests are conducted on checking the integration of multiple code units.
e.g. seedu.easyLog.storage.OrderManagerTest
Hybrids of unit and integration tests. Tests are conducted on multiple code units as well as their logic connections.
e.g. seedu.easyLog.parser.ItemsParserTest
There are multiple ways to run tests for easyLog. Two of them are listed below:
Method 1: Using IntelliJ JUnit test runner
src/test/java
folder and choose Run 'Tests in tp.test'
.Run <test.java>
, where
<test.java>
is the name of the test class (e.g., itemsAddCommandTest
).Method 2: Using Gradle
🔗 Link: Read this Gradle Tutorial from the se-edu/guides to learn more about using Gradle.
gradlew clean test
if you are a Windows user. For macOS or
Linux users, please run the command ./gradlew clean test
instead.Note: If you are new to Gradle, refer to this Gradle Tutorial to learn more about how to use Gradle commands.
We invite you to visit Appendix E: Instructions for Manual Testing to learn more about manual testing for easyLog.
Int this section, we discuss several important aspects of Dev Ops which can shorten the system development life cycle and provide continuous delivery with high software quality.
We use Gradle for tasks related to build automation such as running tests and checking code for style compliance.
To run all build-related tasks:
gradlew build
./gradlew build
BUILD SUCCESSFUL
will be shown in the terminal if all tasks are run successfully. Otherwise,
refer to the error report provided to resolve the issues before trying again.We use Github Actions for continuous integration. No setup will be required for users who fork from the AY2021S2-CS2113T-T09-4/tp repository.
Whenever you create a pull request to the master branch of AY2021S2-CS2113T-T09-4/tp:
We use the IntelliJ IDEA’s coverage analysis tool for coverage reporting. A tutorial on how to install and use this tool can be found here.
You can follow the steps below to make a new release:
gradlew clean shadowJar
./gradlew clean shadowJar
build/libs
directory.v2.1
).Currently, the Gson library is being used for JSON parsing, and the Apache Commons Lang is being used for string processing in easyLog. Below are 2 ways to manage these dependencies.
A simple database application that helps target user to store and access a collection of data electronically from a computer system.
Version | As a … | I want to … | So that I can … |
---|---|---|---|
v1.0 | user | add new items | track the items added to the warehouse |
v1.0 | user | view the items in the warehouse | track the items that are added or not added to the warehouse |
v1.0 | user | remove items | remove the items that are no longer required to be tracked |
v1.0 | user | add new orders | track the orders added to the system |
v1.0 | user | view the orders in the system | track the orders that are added or not added to the system |
v1.0 | user | remove orders | remove the orders that are no longer required to be tracked |
v1.0 | user | clear all items | re-track all the items if there are any problems |
v1.0 | user | clear all orders | re-track all the orders if there are any problems |
v1.0 | user | view all available commands | refer to them when I forget how to use the application |
v1.0 | user | view all items-related commands | refer to them when I forget how to use the items feature |
v1.0 | user | view all orders-related commands | refer to them when I forget how to use the orders feature |
v2.0 | user | create, save data and load existing data | work on another device with the saved data |
v2.0 | expert user | create, save data and load existing data | edit the data file directly |
v2.0 | user | find relevant items | save time by looking through relevant items |
v2.0 | user | find relevant orders | save time by looking through relevant orders |
v2.0 | user | add a new item with a specified unit price | calculate order price more easily |
v2.0 | user | update the unit price of an item | revise unit price or correct mistaken unit price entered earlier |
v2.0 | user | add a new item with its stock | keep track of total number of stock and calculate order price more easily |
v2.0 | user | update the stock of an item | Correct mistaken stock number entered earlier |
v2.0 | user | specify the quantity of a item to add to the order | calculate the total price of the order and update the item inventory correctly. |
v2.0 | user | check the total price of a specific order | feedback to customer when they ask for it and do not have to look through the order list. |
v2.0 | user | update the status of an order | differentiate the orders by their status. |
v2.0 | user | view receipt of a order that is done | check done orders and deal with taxes. |
v2.1 | user | view sales statistics | know what is my most popular items and update stocks accordingly. |
Abbreviation | Full Title | Definition |
---|---|---|
CI | Continuous Integration | Combining parts of a software product to form a whole |
IntelliJ | IntelliJ | An Integrated Development Environment written in Java |
CLI | Command Line Interface | A program that accepts text inputs to execute operating system functions |
GUI | Graphical User Interface | An interface that allows users to interact through graphical icons |
Mainstream OS | Windows, Linux, Unix, OS-X | Operating systems |
Given below are instructions to test easyLog manually.
Note: These instructions only provide a starting point for testers to work on; testers are expected to do more exploratory testing.
Launching easyLog
Check Items
Check if a new item is added in the item list.
Prerequisite: The item to be added is not found in item list.
Testcase: items add pen
followed by 13 12
.
Expected: Item ‘pen’ is added in item list with price $13 and quantity 12.
Check if repeated item is updated.
Prerequisite: The item list already contains item.
Testcase: items update
followed by 1
followed by p
and followed by 15
.
Expected: When input item list
, the first item is priced at 15 with original quantity.
Check it item list is cleared.
Prerequisite: The item list already contains item.
Testcase: items clear
.
Expected: When input item list
, there is a message informing no item in the system.
Check if item is deleted.
Prerequisite: The item list already contains item.
Testcase: items delete 1
.
Expected: When input item list
, the first item in the original list is deleted.
Check if item can be found in list.
Prerequisite: The item list already contains item, e.g. “PS1”.
Testcase: items find PS
.
Expected: A list of item containing “PS” will be shown.
Check if all items can be listed.
Prerequisite: The item list already contains item.
Testcase: items list
.
Expected: A list of items added to item list will be shown.
Check Orders
Check if a new order is added.
Prerequisite:
i. The item list contains some items.
ii. The order list does not contain the same order name.
Testcase: orders add yw
followed by 1 2
followed by stop
.
Expected: A message showing cunstomer [yw] is added.
Check if correct items are added.
Prerequisite:
i. The item list contains some items.
ii. The order list does not contain the same order name.
Testcase: orders add yw
followed by 1 2
followed by stop
followed by orders list
.
Expected: In the list of orders, under yw, two of the first item in item list are added and the
total price is reflected.
Check if the orders are cleared.
Prerequisite:
i. The item list contains some items.
ii. The order list contains some orders, e.g. yw.
Testcase: orders clear
followed by orders list
.
Expected: A message showing no order at the moment.
Check if order deleted.
Prerequisite:
i. The item list contains some items.
ii. The order list contains some orders, e.g. yw.
Testcase: orders delete 1
followed by orders list
.
Expected: The first order in the original order list is deleted.
Check if an order can be found.
Prerequisite:
i. The item list contains some items.
ii. The order list contains some orders, e.g. yw.
Testcase: orders find yw
.
Expected: A list of orders relating to yw will be shown.
Check if status of order can be updated.
Prerequisite:
i. The item list contains some items.
ii. The order list contains some orders, e.g. yw.
Testcase: orders done 1
.
Expected: A message showing the order is completed will be shown. In addition, a receipt will be generated.
Help
Viewing help for easyLog.
Testcase: Input help
.
Expected: A list of commands for easyLog will be shown.
Viewing help for items commands.
Testcase: Input items help
.
Expected: A list of commands for items will be shown.
Viewing help for orders commands.
Testcase: Input orders help
.
Expected: A list of commands for orders will be shown.
Exit easyLog
exit
.