Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CS2113-W14-4] Pharmacy Inventory & Logistics Ledger (PILL) #28

Open
wants to merge 490 commits into
base: master
Choose a base branch
from

Conversation

yijiano
Copy link

@yijiano yijiano commented Oct 1, 2024

Pharmacy Inventory & Logistics Ledger (PILL) is a Command Line Interface (CLI) tool designed to assist in
managing and tracking medicinal inventory.

Copy link

@thomasjlalba thomasjlalba left a comment

Choose a reason for hiding this comment

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

Do remember to ensure your code is more readable for others and to simplify expressions. Keep up the good work

logger.info("Showing specific help for command: " + command);

switch (command.toLowerCase()) {
case "help":

Choose a reason for hiding this comment

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

Maybe you can refactor the magic string?

} else if (j == 0) {
dp[i][j] = i;
} else {
dp[i][j] = min(dp[i - 1][j - 1]

Choose a reason for hiding this comment

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

Maybe you can look to refactor this line to make it more readable?

String closestMatch = null;
int minDistance = Integer.MAX_VALUE;

for (String valid : validStrings) {

Choose a reason for hiding this comment

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

valid might be a bit ambiguous, maybe you can use validString instead?

public Item loadLine(String line) throws PillException {
Item item;
String[] data = line.split(SEPARATOR);
if (data.length == 3) {

Choose a reason for hiding this comment

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

Maybe you can refactor the magic literal to make it more readable

String[] data = line.split(SEPARATOR);
if (data.length == 3) {
try {
item = new Item(data[0], Integer.parseInt(data[1]), LocalDate.parse(data[2]));

Choose a reason for hiding this comment

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

Maybe you could refactor data[0] and so on such that it is more understandable what each variable means before the if statement

Comment on lines +264 to +267
List<Item> filteredItems = items.values().stream()
.flatMap(TreeSet::stream)
.filter(item -> item.getQuantity() <= threshold)
.toList();

Choose a reason for hiding this comment

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

Maybe you can look into refactoring this to make it more readable and less complicated?

String arguments = String.join(" ", Arrays.copyOfRange(splitInput, 1, splitInput.length));

switch (commandString) {
case "exit":

Choose a reason for hiding this comment

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

Maybe you can look into refactoring these magic strings?


@Override
public void execute(ItemMap itemMap, Storage storage) throws PillException {
// Looks stupid, but this way I don't handle Optionals in this class

Choose a reason for hiding this comment

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

Comment on lines +107 to +109
} else {
suggestSimilarCommand(command);
}

Choose a reason for hiding this comment

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

Maybe this can be changed to a guard clause instead to make the happy path more prominent

private final String commandName;
private final boolean verbose;

public HelpCommand(String commandInput, boolean verbose) {

Choose a reason for hiding this comment

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

Maybe you can change the boolean variable name to make it more obvious it is a boolean

Copy link

@Bev-low Bev-low left a comment

Choose a reason for hiding this comment

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

Overall looks neat


<!-- @@author yakultbottle -->

### Storage
Copy link

Choose a reason for hiding this comment

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

I think these classes can have UML diagrams

Example:

```
AddItemCommand command = new AddItemCommand(itemName, quantity, expiryDate);
Copy link

Choose a reason for hiding this comment

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

I think this can be put in the implementation section, following the example they give us.


**API**: PillLogger.java

<img src = "diagrams/PillLogger.png" alt="Component Diagram for PillLogger"/>
Copy link

Choose a reason for hiding this comment

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

This diagram looks like it doesnt follow the standard

Choose a reason for hiding this comment

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

yeah, i think missing some tag and some place should use dotted lines

The ItemMap class contains a key-value pair, implemented as a Map, from the
item name(String) to the item(TreeSet\<Item>)

![](diagrams/ItemMap-ClassDiagram.png)
Copy link

Choose a reason for hiding this comment

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

I dont think this follows the standard also, I am not sure what the dotted box "item" mean on comparable

Copy link

Choose a reason for hiding this comment

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

should do comparable:item


The Item class has three private variables, a name, a quantity, and an
expiry date. An Item may or may not have an expiry date, so we store it
as an Optional, which handles empty values for us without using null.

Choose a reason for hiding this comment

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

could briefly explain why Optional was chosen over null


**API**: PillLogger.java

<img src = "diagrams/PillLogger.png" alt="Component Diagram for PillLogger"/>

Choose a reason for hiding this comment

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

yeah, i think missing some tag and some place should use dotted lines

* Technical Requirements: Any mainstream OS, i.e. Windows, macOS or Linux, with Java 11 installed. Instructions for downloading Java 11 can be found [here](https://www.oracle.com/sg/java/technologies/javase/jdk11-archive-downloads.html).
* Project Scope Constraints: The application should only be used for tracking. It is not meant to be involved in any form of monetary transaction.
* Project Scope Constraints: Data storage is only to be performed locally.
* Quality Requirements: The application should be able to be used effectively by a novice with little experience with CLIs.

Choose a reason for hiding this comment

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

can be more detailed and concrete


#### AddItemCommand

<img src = "diagrams/AddItemCommand-SequenceDiagram.png"/>

Choose a reason for hiding this comment

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

some part like print and log can be simplified


#### AddItemCommand

<img src = "diagrams/AddItemCommand-SequenceDiagram.png"/>

Choose a reason for hiding this comment

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

Would it be better to add some activation bars to show if the objects are working?


The high-level overview of the project structure is as follows:

<img src = "diagrams/High-Level-Overview.png" alt="High Level Overview of PILL"/>

Choose a reason for hiding this comment

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

You may try to consider the direction of arrows. Since it's is MVC model, the arrow from View to Controller might be a two way arrow (e.g. View send request to Controller and Controller response with data?), the same for Controller to Model components


## Design & implementation

{Describe the design and implementation of the product. Use UML diagrams and short code snippets where applicable.}
The project is designed using the Model-View-Controller (MVC) architecture, with the following components:

Choose a reason for hiding this comment

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

Since Model - Controller - View is at a higher level comparing to other classes (e.g. Model contains Item and ItemClass) and they are not really a class as well, you may try to create a hierarchy, just to distinguish between the architecture and the actual implementation. For example:
3. Controller:
3.1. Item
3.2. ItemMap


The UI consists of the following components:

1. **Parser**: The Parser class is responsible for interpreting user input and returning the corresponding command.

Choose a reason for hiding this comment

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

As I think UI is the 'View' part in your architecture, should it be better to make this parser a part of the Controller instead of View? As the Controller in MVC is responsible for handling user input, processing it, and coordinating between the Model and the View, I think the parser is nearer to a Controller component than a View component


<!-- @@author cxc0418 -->

### UI and I/O

Choose a reason for hiding this comment

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

Will it be good to put these implementation into a hierarchy corresponding to your architecture? To make a clearer view of how each component related to the high-level architecture!

Choose a reason for hiding this comment

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

The diagram should not have class symbols (green C) and the arrows should be orthogonal.

Choose a reason for hiding this comment

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

The diagram is missing activation boxes

Choose a reason for hiding this comment

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

The arrows should be orthogonal.

Copy link

@Zackermax Zackermax Oct 30, 2024

Choose a reason for hiding this comment

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

The formatting for the "else" condition in the second section is not formatted properly.

Copy link

@LTK-1606 LTK-1606 left a comment

Choose a reason for hiding this comment

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

Looks neat, but notations used may not follow requirements, some broken links and maybe more diagrams would be better

expiry date. An Item may or may not have an expiry date, so we store it
as an Optional, which handles empty values for us without using null.

![](diagrams/Item-ClassDiagram.png)

Choose a reason for hiding this comment

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

Are your notations used correctly? Should it be "function(): 'return type'"?


#### AddItemCommand

<img src = "diagrams/AddItemCommand-SequenceDiagram.png"/>

Choose a reason for hiding this comment

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

Are these notations correct? Should it include activation bars?


<!-- @@author cxc0418 -->

### UI and I/O

Choose a reason for hiding this comment

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

Should there be more visuals and diagrams to make this clearer?

Comment on lines 13 to 14
- [DateTime](#datetime)
- [Exceptions and Logging](#exceptions-and-logging)

Choose a reason for hiding this comment

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

Are these links supposed to be here? Should they be broken?

philip1304 and others added 30 commits November 12, 2024 06:27
Update high level architecture diagram
Add acknowledgement for XChart
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.