PROJECT: MoneyGoWhere


Overview

MoneyGoWhere is a desktop application which aims to help users keep track of their spending, as well as necessary information such as date, cost and name. Users can also set a budget, set reminders as well as get stats of the spending.

MoneyGoWhere has a Command Line Interface(CLI) for user to interact with as well as a Graphical User Interface(GUI) built using JavaFx. It is written in Java, and has about 15 kLoC.

My Role

I was a developer and was tasked to implement the Budget feature of the program, as well as implemented the ability for users to press the up and down key to traverse their command history. I have also made notable contributions to the User Guide and Developer Guide.

Summary of contributions

This section shows my contributions to the team project.

  • Major enhancement: Implemented the Budget feature of MoneyGoWhere

    • What it does: Allows users to set a monthly budget.

    • Justification: This feature is a core component in the program. One of the key features of the program is to show the user whether or not the user spends within budget.

    • Highlights: This enhancement requires an in-depth of the software architecture. It affects other commands as it affected by certain commands.

  • Minor enhancement: Implemented showbudget command to show users their budget as well as sum of spending in the month set.

  • Minor enhancement: Implemented the ability for users to navigate through previous commands using up/down keys.

  • Code contributed: [Collated code]

  • Other contributions:

    • Project management:

      • Posted user stories as issues

      • PRs reviewed (with non-trivial review comments): (Pull request #87)

    • Enhancements to existing features:

      • Refactored existing class Person to Spending (Pull request #54)

    • Documentation:

      • Did cosmetic tweaks to existing contents of the User Guide: (Pull request #80)

      • Did cosmetic tweaks to existing contents of the Developer Guide:(Pull requests #110, #112)

    • Community:

      • Performed manual testing, reported bugs and suggestions for teammates.(Pull request 1)

      • Performed manual testing, reported bugs and suggestions for other teams in the class. (Pull request 1)

Contributions to the User Guide

The following sections showcase my contributions to the User Guide, which demonstrates my documentation skill to target end-user effectively.

Setting monthly budget : budget

Sets a budget for the current month in the currency set.
Format: budget MONTHLY_BUDGET

  • The monthly budget must be a valid number.

  • The monthly budget amount cannot exceed 1,000,000,000 Singapore Dollars.

  • The monthly budget amount can only have at most 2 digits after the decimal point, regardless if it is trailing zeroes.

    • Examples of valid budget amount:

      • 20

      • 100.01

    • Examples of invalid budget amount:

      • 100.00000

      • 0.0001

Using the budget command will overwrite the currently set budget.

Example:

  • budget 5000
    Sets a budget of $5000 for this month

Expected Output:

The budget for the current month is changed to the set amount.

Showing current budget : showbudget

Shows the current monthly budget, total spending and remaining budget in Singapore Dollars.
Format: showbudget

Expected Output:

The budget for the current month along with the total spending in the month as well as remaining budget is shown.

Going through your command history

Similar to a typical command line interface (CLI), the user may press the up and down key to go through the previous user input history, and display it in the command box. Pressing the up key would go back to the earlier user input command. Whereas pressing the down key would move towards the most recent user input key.

If the user is at the most recent, or the earliest user inputted command, then press the up and down key respectively, no text will be displayed.

Contributions to the Developer Guide

The following sections showcase my contributions to the Developer Guide, which demonstrates my documentation skill from a technical perspective.

Budget feature

The Budget component has two core features:

  1. Allowing the user to set the monthly budget

  2. Calculating the remanding budget after all the spending in the same month.

The budget component allows the users to modify the current monthly budget budget AMOUNT command, where AMOUNT is a double representing the desired monthly budget. The amount cannot exceed 1,000,000,000 Singapore dollars.

For example budget 10000 sets the current monthly budget to 10000.

The budget amount must be a positive number no greater than 1000000000 Singapore dollars and must only have two digits after the decimal point.

The second functionality is done automatically by the program, which finds the total spending in the month and reduces the sum from the budget.

Current Implementation

The current Budget component keeps track of three variables:

  1. The monthly budget amount.

  2. The month the budget is set.

  3. The sum of all spending in the month.

The budget amount and the month the budget is set are saved in the save file, whereas the sum is not. Upon initialization, if a save file is found it will automatically set the monthly budget based on the save file’s options. Once the save file is loaded, the program will check today’s month. If the month has changed, the budget’s set month will change to the current month, and the budget amount will carry over. Once the month has been set, it will go through all spending available and sum up all the spending that are in the set month. It will then keep track of this sum.

Once done initializing, users can set a new monthly budget by executing the budget command. The sequence diagram below demonstrates how the budget command is executed:

SetBudgetSequenceDiagram
Figure 1. Sequence Diagram when setting Budget

The figure above shows the sequence of events that occur to set the monthly budget:

  1. User first enters "budget 100000".

  2. The LogicManager receives the user input and passes it to the SpendingBookParser, which passes it to BudgeCommandParser to parse the user input.

  3. If the user input is valid, a BudgetCommand is then created.

  4. The BudgetCommand is then executed.

  5. The Budget in Model then set to the new amount.

Budget also keeps track of the sum of all spending in order to show the user how much budget the user has left. Initially, it has totaled up all spending in the save file, and then the value is modified when the add, delete and edit commands are called.

The following sequence diagram demonstrates how Budget modifies its value when the add command is used:

BudgetAddSpendingSequenceDiagram
Figure 2. Sequence Diagram for Budget when add command is called

The diagram above shows what happens when an addCommand is being executed. It focuses only on the components that affect Budget.

When adding a new Spending the following steps happen:

  1. The new Spending is passed to Model to be added.

  2. The new Spending is then passed to SpendingBook to be added.

  3. SpendingBook passes the Spending to Budget.

  4. Budget checks whether the Spending is in the same month as it is set or not.

  5. If they are in the same month, the sum of Budget is updated accordingly.

The same applies to delete commands, instead of adding to the sum, it is subtracting from the sum. As well as edit command, which utilizes both add and delete.

Design Consideration

Aspect Alternative 1 Alternative 2

Method to calculate sum of spending

Keep track of the sum and modifies the sum when add, delete and edit commands are called
Pros: Does not waste time to calculate sum. easy to implement.
Cons: We need to keep track of the sum when saving.

Calculate from SpendingList each time
Pros: Seems intuitive.
Cons: It is not efficient, we need to go through the entire each time to calculate sum.

A combination of the two was chosen. During the initialization phase, we read through all spending available, but we handle add, delete and edit commands using option 1.

Command History Feature

Similar to a typical CLI, the up and down key allows the users to cycle through their previous commands.

Implementation

The up and down key mechanism is facilitated by the logic component of MoneyGoWhere. Whenever a user inputs a command, it is stored internally in a list in CommandHistory component of Storage. CommandHistory has an internal index to keep track of its current position in the list.

Additionally, it implements the following operations:

  • Logic#getNextCommand() — Retrieves the next user input command with respect to the current index.

  • Logic#getPrevCommand() — Retrieves the previous user input command with respect to the current index.

The index is initially set to -1, to indicate that there has been no user input. Whenever a user inputs a command, the command is stored at the end of the list and the index is set to the size of the list, to indicate that there are no commands beyond after this point.

Calling getPrevCommand() will cause the index to decrement by 1 and show the user input command stored at that index. When the index is currently 0, or the first user input, pressing the up key will cause the index to result in -1. This returns the empty string, since there are no commands before this point. Any further up key press will have the same outcome, but the index will stay at negative one.

Calling getNextCommand() will cause the index to increment by 1 and the user input at that index will be returned. If the index is currently the last possible value, the last user input, pressing the down key will cause the index to increment by 1, which is outside the list, the empty string will be returned. Any further down key press will have the same outcome but the index will stay at the list size or one after the last possible index.

The following sequence diagram shows how the up/down key mechanism works:

UpDownSequenceDiagram
Figure 3. Sequence diagram for getNextCommand()
getPrevCommand() works the same way as the the sequence diagram above for getNextCommand(). The only difference is which commands get returned.

The following steps explain the sequence diagram:

  1. The user presses the down key.

  2. LogicManager calls StorageManager#getNextCommand().

  3. StorageManager#getNextCommand() calls CommandHistory#getNextCommand()

  4. CommandHistory returns the next user input.

  5. The returned command is then showed to the user in the CommandBox.

To summarize what determines the output when the user presses the down key:

GetNextCommandActivityDiagram
Figure 4. Activity diagram for getNextCommand()

The following steps explain the activity diagram:

  1. The user presses the down key.

  2. CommandHistory will increment its index.

  3. If the index is not out of bounds, the user input at the index will be returned

  4. Else, the index is set to the size of the list, and an empty string is returned.

The sequence diagram and activity diagram for getPrevCommand() are similar to the sequence and activity diagram of getNextCommand() as shown above. The only difference is whether it returns the next command or the previous command.