Skip to content

[CS2113-T18-2] FinancialPlanner#17

Open
ryan1604 wants to merge 711 commits into
nus-cs2113-AY2324S1:masterfrom
AY2324S1-CS2113-T18-2:master
Open

[CS2113-T18-2] FinancialPlanner#17
ryan1604 wants to merge 711 commits into
nus-cs2113-AY2324S1:masterfrom
AY2324S1-CS2113-T18-2:master

Conversation

@ryan1604

@ryan1604 ryan1604 commented Oct 5, 2023

Copy link
Copy Markdown

Financial Planner helps individuals manage their finances effectively and achieve their financial goals. The purpose of such an application is to provide users with a range of tools and features to help them better understand their financial situation.

Brian030601 pushed a commit to Brian030601/tp that referenced this pull request Oct 18, 2023

@maanyos maanyos left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of loggers and assertions.

I think you tried to apply the singleton principle for some classes. It will be covered in one of the lectures, you can also read ahead under week 10's topics. The current implementation can improve a lot, particularly the instance names, and the way they are accessed.

@@ -0,0 +1,5 @@
package seedu.financialplanner.commands;

public abstract class AbstractCommand {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to put abstract in the class name

Comment on lines +58 to +62
private static void loadBudget(String[] split) {
double initial = Double.parseDouble(split[1].trim());
double current = Double.parseDouble(split[2].trim());
Budget.load(initial, current);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to add some safeguards here

String[] split = line.split("\\|");
String type = split[0].trim();
switch (type) {
case "I":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this supposed to be empty?

Comment on lines +17 to +65
public BudgetCommand(RawCommand rawCommand) throws FinancialPlannerException {
command = String.join(" ", rawCommand.args);
if (!command.equals("set") && !command.equals("update")) {
logger.log(Level.WARNING, "Invalid arguments for budget command");
throw new FinancialPlannerException("Please indicate whether budget is to be set or update.");
}

if (command.equals("set") && Budget.hasBudget()) {
logger.log(Level.WARNING, "Invalid command: Trying to set existing budget");
throw new FinancialPlannerException("There is an existing budget, did you mean update?");
}

if (command.equals("update") && !Budget.hasBudget()) {
logger.log(Level.WARNING, "Invalid command: Trying to update non-existent budget");
throw new FinancialPlannerException("There is no budget set yet, did you mean set?");
}

if (!rawCommand.extraArgs.containsKey("b")) {
logger.log(Level.WARNING, "Missing argument /b in command");
throw new IllegalArgumentException("Missing /b argument.");
}

try {
logger.log(Level.INFO, "Parsing budget as double");
budget = Double.parseDouble(rawCommand.extraArgs.get("b"));
} catch (IllegalArgumentException e) {
logger.log(Level.WARNING, "Invalid value for budget");
throw new IllegalArgumentException("Budget must be a number.");
}

if (budget <= 0) {
logger.log(Level.WARNING, "Invalid value for budget.");
throw new FinancialPlannerException("Budget should be greater than 0.");
}

if (budget > Cashflow.getBalance()) {
logger.log(Level.WARNING, "Invalid value for budget");
throw new FinancialPlannerException("Budget should be lower than total balance.");
}

assert budget > 0 && budget <= Cashflow.getBalance() : "Budget should be greater than 0 and less than " +
"or equal to total balance";
rawCommand.extraArgs.remove("b");

if (!rawCommand.extraArgs.isEmpty()) {
String unknownExtraArgument = new ArrayList<>(rawCommand.extraArgs.keySet()).get(0);
throw new IllegalArgumentException(String.format("Unknown extra argument: %s", unknownExtraArgument));
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try using a neater way to put safeguards

Comment on lines +12 to +13
public static final CashflowList INSTANCE = new CashflowList();
public final ArrayList<Cashflow> list = new ArrayList<>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use better names for these lists

import java.util.List;
import java.util.Map;

public class RawCommand {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this class relate to the other commands?

Comment on lines +27 to +32
for (int i = 0; i < cashflowList.list.size(); i++) {
if (cashflowList.list.get(i).toString().contains(description)) {
String output = cashflowList.list.get(i).toString()+" | Index: "+(i+1);
foundedFinancialList.add(output);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can also just iterate through the objects instead of using their indexes

@woodenclock woodenclock left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally good job in making a comprehensive developer guide.
I really like your visualizer, that enhances the UI/UX.
Diagrams were present to support the understanding of the program

Comment thread docs/DeveloperGuide.md
@@ -1,13 +1,249 @@
# Developer Guide

## Table of contents

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of indentation to organize the Table of Contents.
However, since there are 3 types of indentation, could there be a better way of labelling each line? say 1.1.1?
Just a small suggestion.

Comment thread docs/DeveloperGuide.md
* [Glossary](#glossary)
* [Instructions for manual testing](#instructions-for-manual-testing)

## Acknowledgements

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comprehensive acknowledgement of others.
Properly citing third-party libraries and tools ensures transparency and gives credit to the original creators.
This section showcases the developer's integrity and understanding of open-source norms.

Comment thread docs/DeveloperGuide.md

{list here sources of all reused/adapted ideas, code, documentation, and third-party libraries -- include links to the original source as well}

## Design & implementation

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be good to have a Architecture Diagram showcasing your overall design and mechanism of FinancialPlanner. This would give the Developer their needed context should they want to further implement other features to integrate into your program

Comment thread docs/DeveloperGuide.md Outdated
* Advantage: Changes are saved after every command.
* Disadvantage: Executing command might slow down the program when there is a large amount of data to be saved.

### Visualization Feature

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kudos for integrating Xchart!
By having the visual aids, it would definitely allow the user to be aware of their expenses at a glance.
Even though FinancialPlanner is CLI, I like the GUI component added to enhance the UI/UX

Comment thread docs/DeveloperGuide.md

{Describe the design and implementation of the product. Use UML diagrams and short code snippets where applicable.}

### Storage Component

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The relationship between Storage and SaveData/LoadData seems slightly confusing.
Typically, if Storage is a class providing functionalities like saving and loading, it may have methods for those, rather than being connected to abstract classes representing those actions.
Consider redefining these relationships for clarity.

A clearer distinction or some elaboration on what differentiates Cashflow and Budget would be beneficial.

Comment thread docs/DeveloperGuide.md
According to the chart type (Pie/Bar) argument and the Hashmap obtained from the categorizer passed in,
the visualizer displays the specified visualization chart by calling the charting library Xchart.

### Class Diagram

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visualizer seems to have methods that return some kind of chart, but the return types are not indicated.
It would be clearer if return types were included.

The relationship between Categorizer and other classes is not immediately evident.
Perhaps some connecting lines or indications of method calls/dependencies would be helpful.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VIsualizer would do the showing of chart itself. Thus it is a void method call to visualizer to print the chart.

Thanks for the feedback on the class diagram!
Will work on that!

Comment thread docs/DeveloperGuide.md Outdated

![](images/vis/visualisationClass.png)

### Sequence Diagram

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the sequence diagram, it would be beneficial to include return arrows, especially for method calls that yield some kind of result.
The method printDisplayChart(type) is invoked on Ui from VisCommand, but from the class diagram, it seems like the method belongs to the Visualizer class. This discrepancy should be resolved for consistency.
Or am I just confusing myself?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I can see the confusion. printDisplayChart prints a message telling the user that a chart is being displayed. Visualizer has a method for displaying the actual chart. I have renamed the method for UI to make it clearer. I will add the return arrows as well!

@danielpappa danielpappa left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall great DG! Very detailed description and plenty of diagrams and code snippets to transmit the content in an intuitive way. Maybe could try to make it more coherent by paying attention to how each detail is actually formatted (colors, bullet points etc.). Kudos also for the use of diagrams!

Comment thread docs/DeveloperGuide.md

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall very good DG, very precise and in depth analysis of the code and detailed description.
Maybe could use a single and coherent way of using bullet points (right now the DG contains >>, 1), 1. and Step 1). This could make the DG look as if actually written by a single person.

Comment thread docs/DeveloperGuide.md Outdated
## Acknowledgements

**Xchart (A Simple Charting Library for Java)**
- author: KNOWN

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there is a typo here: shouldn't it be author: KNOWM?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THanks for spotting!

Comment thread docs/DeveloperGuide.md Outdated

## Design & implementation

{Describe the design and implementation of the product. Use UML diagrams and short code snippets where applicable.}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could add a brief introduction and overview of your Financial Planner, explaining the goal and purpose as well as its rough overall design in form of an arbitrary architecture diagram. This would also allow further developers an immediate insight into your product and align them with your ideas and implementations from the start.

Comment thread docs/DeveloperGuide.md Outdated
* Saving the data once upon exit (Currently implemented):
* Advantage: Better efficiency and performance of the program.
* Disadvantage: If the program crashes or exits incorrectly, data will not be saved.
* Saving the data after every command:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it should be specified whether this way is currently implemented or not (as is done for the other option) to keep the considerations coherent. Right now I assume it is not, but I would still not be sure.

Comment thread docs/DeveloperGuide.md
Output

`Displaying piechart for expense`
A message will be shown telling you that the chart is being displayed

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice implementation. This feature is straightforward and meets the user requirements.

Comment thread docs/DeveloperGuide.md

### Class Diagram

![](images/vis/visualisationClass.png)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the text above Command and RawCommand are omitted, whereas it seems like there should be a dependency between the Categorizer and VisCommand. Maybe some more detailed steps could help clarify these doubts.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback, will add it in!

Comment thread docs/DeveloperGuide.md

Overall

![](images/vis/visualisationSequence.png)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could include return arrows. Also it could perhaps be helpful to make the alt and opt boxes coherent by applying the coloring to all sequence diagrams in the DG (helps create impression that DG was written by a single person).

@ChoonSiang ChoonSiang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall very nice use of diagrams, except some minor bugs in the UML diagrams

Comment thread docs/DeveloperGuide.md

Overall

![](images/vis/visualisationSequence.png)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a <<class>> above Categorizer and Visualizer?

Comment thread docs/DeveloperGuide.md Outdated

#### Diagrams
Given below is the class diagram showing the class structure of the add income/expense mechanism:
![](images/CashflowClassDiagram.png)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you will want to refer to the PlantUML docs to remove the C and E circles to comply with our standard of UML diagrams.

Comment thread docs/DeveloperGuide.md
According to the cashflow type (Income/Expense) arugment passed in, the Categorizer sorts the
specified cashflow entry according to type using a Hashmap which is returned and used by the Visualizer

Visualizer's Role:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use charts for user to visualize their income/expenses.

Comment thread docs/DeveloperGuide.md Outdated
![](images/CashflowClassDiagram.png)

Given below is the sequence diagram showing the add income/expense mechanism:
![](images/AddCashflowSequence.png)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Activation Bar is missing in this diagram. May want to refer to the Sequence Diagram examples in the CS2113 Website.

Comment thread docs/DeveloperGuide.md

This feature has 5 functions, `set`, `update`, `delete`, `reset`, and `view`.

![](images/Budget.png)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of reference frames for neater view of the diagram.

@ChoonSiang ChoonSiang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add on to previous comment

Comment thread docs/DeveloperGuide.md


## Product scope
### Target user profile

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to add more User Stories to accurately reflect your actual feature implementation in each version.

Brian030601 pushed a commit to Brian030601/tp that referenced this pull request Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.