Skip to content

Commit

Permalink
Merge pull request #286 from EugeneTeu/ppp
Browse files Browse the repository at this point in the history
minor typo and changes
  • Loading branch information
zhixianggg authored Nov 11, 2019
2 parents 2ee46ee + 24a2203 commit a2a758c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 82 deletions.
73 changes: 33 additions & 40 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,11 @@ image::ArchitectureSequenceDiagram.png[]

The sections below give more details of each component.

// tag::UiUG[]

[[Design-Ui]]
=== UI component

// tag::UiUG[]
.Structure of the UI Component
image::UiClassDiagram.png[]
image::UiClassDiagram.png[width="400"]

*API* : link:{repoURL}/src/main/java/seedu/address/ui/Ui.java[`Ui.java`]

Expand Down Expand Up @@ -187,18 +185,13 @@ This section describes some noteworthy details on how certain features are imple

=== Statistics Calculation and Chart generation feature


==== Implementation

This statistic calculation and chart generation feature extends `Seller Manager Lite` which allows seller to quickly
generate total statistics from their `DataBooks`, through the use of a `statistic`
module that handles this calculation.

There is three type of statistic to be calculated and only on `completed orders`:
module that handles this calculation. There is three type of statistic to be calculated and only on `completed orders`:

* `Profit`
* `Cost`
* `Revenue`
* `Profit` `Cost` `Revenue`

It implements the following mode of operations:

Expand All @@ -220,13 +213,11 @@ analogous to the output mode, there are 2 types of methods in this module, one t
`String` and the other and `XYChart.Series<String,Number>`

* Methods that return a `String`:

** `calculateTotalProfitOnCompleted(...)`
** `calculateTotalRevenueOnCompleted(...)`
** `calculateTotalCostOnCompleted(...)`

* Methods that return a `XYChart.Series<String,Number>`:

** `calculateTotalProfitOnCompletedGraph(...)`
** `calculateTotalRevenueOnCompletedGraph(...)`
** `calculateTotalCostOnCompletedGraph(...)`
Expand All @@ -251,7 +242,6 @@ since it meant extending the `Model` class with a statistic model, than having t
this value.
*** Pros: Easy to implement on top of AB3
*** cons: Seller will be unable to obtain an instance of past statistics at each point without storing the history of the statistics somewhere, since any change in the database / models will cause the values to change
*** cons: Will bloat the UI since there will be extra details to be displayed and there is an extra panel on screen.

* Alternative Design (current design) :
** `Statistics` module will exist outside of the current packages and be standalone. `Logic` will handle communication with
Expand All @@ -264,10 +254,8 @@ this module from `UI`. Respective Statistics will then be obtained from `Logic`

Given that consideration, we decided that it will be the `UI` to trigger this call to `Logic` for calculation
and then display the result of that call. Thus when Statistics need to be shown, the `UI` module will query the
`Logic` for the respective data

One of the motivation for this approach was to, as much as possible, maintain the architecture that is already in place in AB3.

`Logic` for the respective data One of the motivation for this approach was to,
as much as possible, maintain the architecture that is already in place in AB3.
Furthermore, given that this feature requires date input from the user, we will need to find a way to get `UI` to send
the data to make that query to logic. For the old AB3 implementation, `CommandResult` only contains a feedback to user
with the actual changes on data done with a call to model during `execute(model)`.
Expand All @@ -278,22 +266,21 @@ with the actual changes on data done with a call to model during `execute(model)
We decided to extend this command pattern by creating a `statsPayload` object. This object will hold the user
queries for the statistic calculation (if there is any) and be bundled along with the `CommandResult` class to the
`UI` to use in its query to logic. When the Ui executes the command to logic, the `CommandResult` is returned with
this object, which the `UI` will then use to communicate to `Logic`.
this object, which the `UI` will then use to communicate to `Logic`.The resulting change
is that the `commandResult` type will have a slightly different behaviour.

The resulting change is that the `commandResult` type will have a slightly different behaviour. *All `commands` that
*All `commands` that
are not `statsCommand` will call the default constructor of the `commandResult` class, where there is an
`Optional.empty()` in place of the `StatsPayload` * .
`Optional.empty()` in place of the `StatsPayload`* .

All `statsCommand` type will have call the constructor of `commandResult` class and pass the `StatsPayload` object in.

The key motivation behind this idea of a payload was to be able to encapsulate details about the calculation inside a
single object, passed it to the appropriate place to be "unwrapped" when needed. This unwrapping is done by the
`mainWindow` class in the application and subsequently the data is passed to the `statistic` module.


A high level view of the packages working together:

image::statsOverallClassDiagram.png[]
image::statsOverallClassDiagram.png[width="300", align="center"]

==== Current Implementation

Expand All @@ -305,56 +292,52 @@ Below is a more in-depth explanation at each step.
For the default mode with no date, the steps are almost the same, except that
`DefaultStatisticsWindow` is called in place of `StatisticsWindow`*


Step 1: User inputs a stats command e.g `generate-s s/REVENUE d1/2018.12.13 d2/2019.11.13`.

The commandBox executes it and the `MainWindow` runs its `executeCommand(commandText)` method.

Referring to the sequence diagram below,this results in `logic.execute(commandText)` being called and
Referring to the sequence diagram below, this results in `logic.execute(commandText)` being called and
the `statsCommandParser` parses the input from the user, returning a
`Command` object

Seen here is the sequence diagram of the first step

image::StatsCommandSequenceDiagram1.png[]
image::StatsCommandSequenceDiagram1.png[width="400", align="center"]

Step 2: the logic then calls `command.execute(command)` (refer to the second set of arrow coming out of `LogicManager`)
Step 2: the logic then calls `command.execute(command)`

When this happens, the `StatsCommand` execute triggering a call to create the new `StatsPayload`. Then this is used to
create a new `CommandResult` object and returns that to `Logic` , completing the execution of the user input command.

Seen here is the sequence diagram of the second step

image::StatsCommandSequenceDiagram2.png[]
image::StatsCommandSequenceDiagram2.png[width="400", align="center"]

Shown below is a quick summary of step 1-2 (Full complete diagram):

image::StatsCommandSequenceDiagram.png[]
image::StatsCommandSequenceDiagram.png[width="600", align="center"]

Step 3: After the logic component completes it execution and return a `CommandResult`, the `UI` will call
`performUiChanges` that handles the specific `UI` change.

This then results in the `statsPayload` class being passed to `Logic` class and subsequently the `statistics` module,
`performUiChanges` that handles the specific `UI` change.This then results in the `statsPayload` class being
passed to `Logic` class and subsequently the `statistics` module,
where the appropriate calculation will take place.


Step 4: `Statistic Manager` calculates the date

Depending on the input, the `Statistic Manager` will calculate the value and return that, either in the form of
a `String` or a `XYChart.Series<String, Number>`
a `String` or a `XYChart.Series<String, Number>`.

Step 5: with this output from logic, `Statistic Window` will then handle the diplaying of the statistic, be it in chart
form or string form. With this the feature has finished executing! Attached below is the summary for step 3-5:

image::StatisticsCalculationUI.png[]
image::StatisticsCalculationUI.png[width="400", align="center"]


==== Current Version `v1.4`:

Here are some screenshots of the current product:
Here is a screenshot of the current product:

image::StatsExampleGraph.png[width="600"]
image::StatsExampleGraph.png[width="300" align="center"]]

image::StatsExampleDefault.png[width="600"]

==== Limitations / note to developers:

Expand Down Expand Up @@ -1063,3 +1046,13 @@ These instructions only provide a starting point for testers to work on; testers
.. When the application is relaunched, it will check for the validity of the data.
Any corrupted data in any of the data files (customer, phone, order, schedule, archived order) will cause SML to start with an empty data book for that particular corrupted type of data.



=== Testing Statistics

. Display statistics between 2 dates

.. Prerequisites: Ensure that archive order panel has suitable `Completed` and `scheduled` orders. Only these orders
will show up in the calculation
.. Test case: `generate-s s/revenue d1/2018.12.13 d2/2019.11.13`
Expeected: Chart is displayed in popup window
14 changes: 6 additions & 8 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -809,13 +809,13 @@ Lacking any of this will cause its non-inclusion into the statistics calculation
The value calculated is the sum over the total time period within a month, meaning that it will take the date period,
calculate the statistics for orders within that time period, split it by month and display it.

e.g `revenue` between 2019.11.12 and 2019.11.29 will calculate the order between this 2 dates, sum up the revenue
e.g Total `revenue` between 2019.11.12 and 2019.11.29 will calculate the order between this 2 dates, sum up the revenue
(as it falls within a single month) and
display this value.

* Accepts two types of input:
** Without date input
** with date input +
** Without date input - display total value for that particular statistics
** with date input - displays chart (Monthly value) and total value for that particular statistics +

Generates the statistics with no date input. +

Expand All @@ -829,7 +829,7 @@ The argument must match this three words perfectly.
Shown below:


image::StatsExampleDefault.png[width="600"]
image::StatsExampleDefault.png[width="300"]


Generates the statistics with date input in chart format (in pop-up modal dialog). +
Expand All @@ -839,8 +839,9 @@ Format for date is in YYYY.MM.DD e.g `2019.05.12`

Shown below:

image::StatsExampleGraph.png[width="600"]
image::StatsExampleGraph.png[width="300"]

// end::statisticsCommandUG[]
[TIP]
Date should be in the format YYYY.MM.DD with valid year, month and date. Only dates from year 1970 onwards are valid.
[TIP]
Expand Down Expand Up @@ -878,7 +879,6 @@ when the remaining statistic windows are closed manually.
** Do not be alarmed if the window does not pop up immediately upon click. For larger data sets
we estimate at least a few seconds before the window will be loaded.


==== Average Statistics `[coming in v2.0]`
** More advanced commands like `average profit` etc

Expand All @@ -888,8 +888,6 @@ we estimate at least a few seconds before the window will be loaded.
==== Export Chart to PDF `[coming in v2.0]`
** User will be able to export their charts to pdf with a click of a button.

// end::statisticsCommandUG[]

=== Exiting the program : `exit`

Exits the program. +
Expand Down
50 changes: 16 additions & 34 deletions docs/team/eugeneteu.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,29 @@ It was written over the span of 2 months and morphed from the original Address-b
*** Date input: This mode is to produce a monthly chart view of the statistics

** Justification: Being business owners, this feature should be very essential for the owners to be able to track their statistics and numbers while running their day to day operations. This allows them to more easily plan and monitor their business while using these numbers.
By having this feature, the users of this app can review their performance of their products over the past few months, which is essential to business owners.
** Highlights: This feature cut across several layers in the entire project e.g logic, UI, model and hence designing it in such a way that it was able to work with the existing Model View Controller architecture was a very important albeit tedious step.
It required an in-depth analysis of design alternatives. This design choice is elaborated below in the developer guide writeup.
*** The implementation was also challenging as I made very sure no to violate any of the SOLID principles. At the same time, we were also still deciding how to implement the rest of the architecture for the other features.
*** The implementation was also challenging as I made very sure no to violate any of the SOLID principles.
At the same time, we were also still deciding how to implement the rest of the architecture for the other features.
There was a very strong and conscientious effort to make the code easily extendable as there is a high possibility that this feature will have to scale exponentially.
*** A total of 4 attempts of refactoring was needed for me to reach the current version of the main feature.

** Credits: The https://commons.apache.org/proper/commons-math/[apache commons math libraries] was used in the actual calculation. However, the main difficulty of this feature does not come from the actual calculation but extracting the correct and appropiate data needed for this in the appropiate manner.
** Credits: The https://commons.apache.org/proper/commons-math/[apache commons math libraries] was used in the actual calculation. The main difficulty of this feature come from extracting the correct and appropiate data needed and in the appropiate manner.

* *Other Major enhancement*:
** My other contributions to the codebase is as follows:
*** Complete overhaul of User Interface. This includes generating the FXML files, creating the controller files, importing and GUI tests.
*** UI commands. This includes the command that is directly related to switching of UI e.g `switch-o` which allows the user to switch their their focused tab panel with a command

* *Code contributed*:

* contributed total almost 7k LOC:

** 3k+ functional & 3k+ test code: https://nus-cs2103-ay1920s1.github.io/tp-dashboard/#search=eugeneteu&sort=groupTitle&sortWithin=title&since=2019-09-06&timeframe=commit&mergegroup=false&groupSelect=groupByRepos&breakdown=false&tabOpen=false[code]


* *Other contributions*:

** Project management:
*** Managed releases `v1.35` (1 release) on GitHub
*** *DevOps and Tools*
**** Set up organization and team repo
**** Managed Milestones deliverables: https://github.com/AY1920S1-CS2103T-T09-4/main/pull/175[#175]
**** Integrated a third party library (Travis CI) to the project (https://github.com/AY1920S1-CS2103T-T09-4/main/pull/53[#53])
**** Integrated a third party library (AppVeyor) to the team repo (https://github.com/AY1920S1-CS2103T-T09-4/main/pull/53[#53])
**** Integrated a third party library (Coveralls) to the team repo
**** Integrated a third party library (Travis CI) to the project (https://github.com/AY1920S1-CS2103T-T09-4/main/pull/53[#53]), (AppVeyor) to the team repo (https://github.com/AY1920S1-CS2103T-T09-4/main/pull/53[#53]) and (Coveralls) to the team repo


** Enhancements to existing features:
Expand All @@ -55,43 +49,29 @@ It required an in-depth analysis of design alternatives. This design choice is e
https://github.com/AY1920S1-CS2103T-T09-4/main/pull/136[#136], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/129[#129])

*** Add Tabbed panels for UI. This includes writing the FXML files and controllers for the UI elements (Pull Requests: https://github.com/AY1920S1-CS2103T-T09-4/main/pull/72[#72], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/192[#192], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/145[#145], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/169[#169] )

*** Add command to interact with Tabbed panels for UI (Pull Requests: https://github.com/AY1920S1-CS2103T-T09-4/main/pull/110[#110] , https://github.com/AY1920S1-CS2103T-T09-4/main/pull/76[#76])

*** Ported GUI tests into code base and added to it (Pull Requests: https://github.com/AY1920S1-CS2103T-T09-4/main/pull/103[#103], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/139[#139])

*** Wrote tests for Statistics Module, Storage Module (Json) (Pull Requests: https://github.com/AY1920S1-CS2103T-T09-4/main/pull/174[#174], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/171[#171], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/160[#160], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/83[#83])

***

** Documentation:
*** Wrote About us page: https://github.com/AY1920S1-CS2103T-T09-4/main/pull/48[#48]

*** Tweaked to existing contents of the User Guide: https://github.com/AY1920S1-CS2103T-T09-4/main/pull/140[#140]

*** Created new UML model diagrams for Developer Guide: https://github.com/AY1920S1-CS2103T-T09-4/main/pull/159[#159]


** Community:

*** Participated in PRs review(with non-trivial review comments): ( https://github.com/AY1920S1-CS2103T-T09-4/main/pull/61[#61], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/62[#62], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/63[#63], https://github.com[#42], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/66[#66] , https://github.com/AY1920S1-CS2103T-T09-4/main/pull/68[#68], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/72[#72], https://github.com/AY1920S1-CS2103T-T09-4/main/pull/141[#141])

*** Contributed to forum discussions and shared my solution on enabling GUI tests on Travis CI: https://github.com/nus-cs2103-AY1920S1/forum/issues/141[#141]

*** Reported bugs and suggestions for other teams in the class (examples: https://github.com/AY1920S1-CS2103T-T09-2/main/issues/207[#207] )

** Summary:

*** Contributed total almost 7k LOC: 3k+ functional & 3k+ test code: https://nus-cs2103-ay1920s1.github.io/tp-dashboard/#search=eugeneteu&sort=groupTitle&sortWithin=title&since=2019-09-06&timeframe=commit&mergegroup=false&groupSelect=groupByRepos&breakdown=false&tabOpen=false[code] or (https://nus-cs2103-ay1920s1.github.io/tp-dashboard/#search=eugeneteu&sort=groupTitle&sortWithin=title&since=2019-09-06&timeframe=commit&mergegroup=false&groupSelect=groupByRepos&breakdown=false&tabOpen=false)
*** Over 41 https://github.com/AY1920S1-CS2103T-T09-4/main/pulls/EugeneTeu[Pull requests] on Github

*** Over 37 https://github.com/AY1920S1-CS2103T-T09-4/main/issues/created_by/EugeneTeu[issues] on Github

*** Complete Contribution https://nus-cs2103-ay1920s1.github.io/tp-dashboard/#search=eugeneteu&sort=groupTitle&sortWithin=title&since=2019-09-06&timeframe=commit&mergegroup=false&groupSelect=groupByRepos&breakdown=false&tabOpen=false[here]
*** Complete Contribution https://nus-cs2103-ay1920s1.github.io/tp-dashboard/#search=eugeneteu&sort=groupTitle&sortWithin=title&since=2019-09-06&timeframe=commit&mergegroup=false&groupSelect=groupByRepos&breakdown=false&tabOpen=false[here] or (https://nus-cs2103-ay1920s1.github.io/tp-dashboard/#search=eugeneteu&sort=groupTitle&sortWithin=title&since=2019-09-06&timeframe=commit&mergegroup=false&groupSelect=groupByRepos&breakdown=false&tabOpen=false)

== 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._
|===
Expand All @@ -105,16 +85,18 @@ include::../UserGuide.adoc[tag=statisticsCommandUG]
|===

* My Contributions are:
** Created the architecture diagram
** Created logic diagram
** Wrote the User Interface part of the DG
** Created the architecture, UI and Logic diagram (refer to DG portion with these diagrams)
** Wrote the User Interface part of the DG (omitted limitations to user part due to length constraint of PPP)
** Wrote the Statistic Feature in the DG


include::../DeveloperGuide.adoc[tag=architectureDiagram]\
***
include::../DeveloperGuide.adoc[tag=logicDiagram]
//include::../DeveloperGuide.adoc[tag=architectureDiagram]

//include::../DeveloperGuide.adoc[tag=logicDiagram]
***
include::../DeveloperGuide.adoc[tag=UiUG]
***
include::../DeveloperGuide.adoc[tag=statisticsCommand]

***

0 comments on commit a2a758c

Please sign in to comment.