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

[CS2113T-W11-1] SysLib CLI #6

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

Conversation

yingx9
Copy link

@yingx9 yingx9 commented Oct 4, 2023

SysLib CLI is a program designed specially for system librarians to manage their work and
responsibilities. Using intuitive commands, view, add, delete, and find books from the library
inventory without any hassle.

Brian030601 pushed a commit to Brian030601/tp that referenced this pull request Oct 13, 2023
…unit-tests

Add JUnit tests for flashcards
Copy link

@Musfirahe0556596 Musfirahe0556596 left a comment

Choose a reason for hiding this comment

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

Good! But here are some code quality violations to consider (I have also created Issues for each individual member)


public class Parser {

public List<Resource> resourceList = new ArrayList<>();

Choose a reason for hiding this comment

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

Plural form should be used on names representing a collection of objects.

boolean matchFound = matcher.find();

if (matchFound) {
if (matcher.group(2).equalsIgnoreCase("b")) {

Choose a reason for hiding this comment

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

"b" is a magic literal - would be good if its placed as a named constant

Comment on lines 92 to 106
Matcher gMatcher = gPattern.matcher(matcher.group(5));
boolean gMatchFound = gMatcher.find();

String[] args = new String[6];

if (matchFound) {
args[0] = matcher.group(1).trim(); // id
args[1] = matcher.group(2).trim(); // title
args[2] = matcher.group(3).trim(); // author
args[3] = matcher.group(4).trim(); // tag
if (gMatchFound) {
args[4] = gMatcher.group(1).trim(); // isbn
args[5] = gMatcher.group(2).trim(); // genre
} else {
args[4] = matcher.group(5).trim(); // isbn

Choose a reason for hiding this comment

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

Magic literals (e.g. group(<5>)) - would be good if the numbers are placed as a named constant.

put("add", new AddCommand());
}
};
public void process(String response) {

Choose a reason for hiding this comment

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

Could rename the method process() better (e.g. process what?)

}
public int parseInt(String value){
try {
int num = Integer.parseInt(value);

Choose a reason for hiding this comment

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

Could rename the variable num better to indicate what it is

String[] value = parseArgument(statement);
validate(statement, value);

if (value[3]==null && value[2]==null && value[1]==null && value[0]==null) {

Choose a reason for hiding this comment

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

Magic literals e.g. value[<3>]- would be good if it is a named constant.

ArrayList<Resource> matchedResources = new ArrayList<>();
for (Resource r: parser.resourceList){
Book b = (Book) r;
if (b.getTitle().equals(value[3]) || b.getISBN().equals(value[1]) || b.getAuthor().equals(value[2])){

Choose a reason for hiding this comment

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

Magic literals e.g. value[<3>]- would be good if it is a named constant.

/*
validate will include str
*/
public void validate(String statement, String[] value) throws IllegalArgumentException{

Choose a reason for hiding this comment

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

Could rename the method validate() better (e.g. validate what?)

/*
validate will include str
*/
public void validate(String statement, String[] value) throws IllegalArgumentException{

Choose a reason for hiding this comment

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

The argument String[] value should be in plural form.

public void execute(String statement, Parser parser) throws SysLibException {
int id = parseInt(parseArgument(statement)[0]);
assert id > 0;
ArrayList<Resource> toRemove = new ArrayList<>();

Choose a reason for hiding this comment

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

Plural form should be used on names representing a collection of objects.

Choose a reason for hiding this comment

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

would it be better for the arrow in the condition where containsKey is false to show some kind of exception being invoked?

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 have some textual explaination of notEqualsIgnoreCase in the developer guide as it is quite ambiguous from the diagram what purpose it serves

Choose a reason for hiding this comment

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

Should the containsKey == false section be below the portion with the Command portion, because the Command portion only comes into play in the case where containsKey is true. Currently the containsKey == false portion is overlapping with the Command block


`add` has seven options:
- add /id [id] /t [title] /a [author] /tag [tag] /i [isbn]
- add /id [id] /t [title] /a [author] /tag [tag] /i [isbn] _/g [genre] /s [status]_

Choose a reason for hiding this comment

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

What does the italics represent? Perhaps more explaination can be added to the DG to explain it. I am not sure if it is there to highlight the difference or to indicate that they are optional tags.

Copy link

@yicheng-toh yicheng-toh left a comment

Choose a reason for hiding this comment

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

Good job on the DG.

Choose a reason for hiding this comment

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

image
One of the bar has a return arrow while another doesn't. Perhaps you could add the arrow in the second circle or you could add return type in the first circle.

Choose a reason for hiding this comment

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

image
Should the else box be extended all the way?

Copy link

@antrikshdhand antrikshdhand left a comment

Choose a reason for hiding this comment

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

Overall a nice DG, however the verbose sequence diagrams could be improved.


#### Sequence Diagram

<img src="images/FindSequenceDiagram.png" />

Choose a reason for hiding this comment

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

This sequence diagram is quite verbose. All return values and method calls are written with sample arguments provided, which is not necessary for a high-level diagram.


#### Sequence Diagram
The following sequence diagram shows how the add function works:
<img src="images/AddSequenceDiagram.png"/>

Choose a reason for hiding this comment

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

It's a good diagram in many ways, however the size could be much more compact without low-level details such as exactly what method is called or what text is passed into each argument.

Comment on lines 128 to 146
Step 1. The user inputs the command: `add /id 0005 /t Frankenstein /a Mary Shelley /i FKS0001 /tag B /g Gothic, Fiction`

Step 2. The `UI` component forwards the input to `SYSLIB`, which in turn passes it to the `PARSER`.

Step 3. The `PARSER` processes the command and determines that it contains a valid key (`add`). It then calls
`ADDCOMMAND#execute(statement: String, this: Parser)` with the input command.

Step 4. The `ADDCOMMMAND` component receives the command and performs the following operations:
- Calls `ADDCOMMAND#parseArgument(statement: String)` to extract values for ID, title, author, ISBN, tag, and genres.
- Calls `ADDCOMMAND#validate(statement: String, values: String[])` to ensure the validity of the input command.

Step 5. The `COMMAND` component processes the input command to ensure that it meets the required format and constraints.
It prepares the argument values for further processing.

Step 6. Since the `tag` argument in the input command indicates that it is a book, the `ADDCOMMAND` determines that the
key is equal to `b` (ignoring case). It then creates a new `Book` object using the parsed values (title, ISBN, author,
genres, ID).

Step 7. The newly created book is forwarded to the `PARSER` to be added to the `resourceList`.

Choose a reason for hiding this comment

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

A well-written, detailed explanation of the process. Great for a future developer!

Copy link
Member

@skylee03 skylee03 left a comment

Choose a reason for hiding this comment

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

LGTM!

## Design & implementation
## Setting Up & Getting Started

1. Fork the repo at https://github.com/AY2324S1-CS2113T-W11-1/tp.
Copy link
Member

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 use hyperlinks?

Comment on lines 25 to 28
- `UI`: User Interaction
- `Parser`: Parsing User Response
- `Command`: Command Executor
- `Data`: Holds the data of SysLib
Copy link
Member

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 indicate where other packages (e.g., storage, common, etc.) belong?

Comment on lines 49 to 52
- `find /id [ID]`
- `find /t [TITLE]`
- `find /a [AUTHOR]`
- `find /i [ISBN]`
Copy link
Member

Choose a reason for hiding this comment

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

According to the textbook, we are suggested to use * instead of - for bullet-points, but it is optional to follow it.

Comment on lines +62 to +64
1. Parse the filters and their associated values.
2. Filter the resources based on the given filters.
3. Display the matching resources.
Copy link
Member

Choose a reason for hiding this comment

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

According to the textbook, we are suggested to use generic numbering for ordered lists, but it is optional to follow it.


#### Example Usage Scenario

Step 1. The user inputs the command: `add /id 0005 /t Frankenstein /a Mary Shelley /i FKS0001 /tag B /g Gothic, Fiction`
Copy link
Member

Choose a reason for hiding this comment

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

Why is "Step 1." in bold above but not here? Is it better to have a unified style?

Copy link
Member

Choose a reason for hiding this comment

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

This picture is too wide! Try to avoid repeating the parameters that are too long.

Copy link
Member

Choose a reason for hiding this comment

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

One activation bar corresponds to one method call. Therefore :Command should have 2 activation bars.

Copy link
Member

Choose a reason for hiding this comment

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

AddCommand is a subclass of Command, and the :AddCommand instance is just calling the methods of it self. Would it be more accurate to regard parseArgument and validateStatement as its members?

Copy link
Member

Choose a reason for hiding this comment

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

Would it be more accurate to explicitly mark :AddCommand as destroyed?

Copy link
Member

Choose a reason for hiding this comment

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

One activation bar corresponds to one method call. Therefore :Command should have 2 activation bars.

Copy link
Member

Choose a reason for hiding this comment

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

Would it be more accurate to use -> instead of --> for the arrow of warning?

Copy link
Member

Choose a reason for hiding this comment

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

FindCommand is a subclass of Command, and the :FindCommand instance is just calling the methods of it self. Would it be more accurate to regard parseArgument and validateStatement as its members?

Copy link
Member

Choose a reason for hiding this comment

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

One activation bar corresponds to one method call. Therefore :Command should have 2 activation bars.

Copy link
Member

Choose a reason for hiding this comment

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

Would it be more accurate to complete the return arrows?
1698917627170

docs/AboutUs.md Outdated
Copy link
Member

Choose a reason for hiding this comment

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

The table is not displayed properly. Please try to add an empty line between the table and the # About us.

Copy link
Member

Choose a reason for hiding this comment

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

The avatars are too big! Maybe making the picture smaller will look better!

Comment on lines 30 to 35
____ _ _ _ ____ _ ___
/ ___| _ _ ___| | (_) |__ / ___| | |_ _|
\___ \| | | / __| | | | '_ \ | | | | | |
___) | |_| \__ \ |___| | |_) | | |___| |___ | |
|____/ \__, |___/_____|_|_.__/ \____|_____|___|
|___/
Copy link
Member

Choose a reason for hiding this comment

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

Spectacular ASCII art!


SysLib currently consists of four main components:

- `UI`: User Interaction

Choose a reason for hiding this comment

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

UI should be User Interface?

Comment on lines 32 to 39
### UI Component

### Parser Component

### Command Component


### Data Component

Choose a reason for hiding this comment

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

Maybe can add some content after each title

Copy link
Member

Choose a reason for hiding this comment

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

Maybe can add some content after each title

I think they just have not started to write them… 😂


#### Sequence Diagram

<img src="images/FindSequenceDiagram.png" />

Choose a reason for hiding this comment

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

Should add a conditional block for returning legalArgumentException? Since it's try catch block so not necessary to throw exception


#### Sequence Diagram

<img src="images/FindSequenceDiagram.png" />

Choose a reason for hiding this comment

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

if you are calling a function resourceList should be like resourceList() in the sequence diagram

Comment on lines 248 to 257
Commands available:
add: adds a new resource to the library inventory.(e.g. add /id ID /t TITLE /a AUTHOR /tag TAG /i ISBN [/g GENRE])
delete: deletes the resource with the specified ID from the library inventory. (e.g. delete /id 123456789)
list: list all resources OR filter by certain tags or genre.(e.g. list /tag B /g Fiction
find: find a resource by title, author, ISBN or given id. (e.g. find /i 9780763630188)
edit: Edit a listing by entering its isbn to update its details. (e.g. edit /i 123 /t NEW_TITLE /a NEW_AUTHOR)
exit: displays a farewell message and exits the program (e.g. exit)
For more information, please refer to our user guide at:https://ay2324s1-cs2113t-w11-1.github.io/tp/UserGuide.html
____________________________________________________________
```

Choose a reason for hiding this comment

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

A bit hard to read

@junhyeong0411
Copy link

image

When you use exception on sequence diagram, I think using Alt block will be better.
Then you can also show that the activation bar brokes because of IllegalArgumentException.

@junhyeong0411
Copy link

image

In these parts, I think it is better to use alt blocks to show if-else statement.
Those bars are self-invocation bars, but actually your code doesn't self-invoke in that part.

@junhyeong0411
Copy link

image

When writing components name, I think matching the Uppercase and Lowercase with the actual code is better.
(For example, Ui, Parser, ...)

@junhyeong0411
Copy link

image

In this part, I think user can be more detailed.

- `Command`: Command Executor
- `Data`: Holds the data of SysLib


Choose a reason for hiding this comment

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

Consider adding class diagrams to show how the different classes are related to each other.

#### Sequence Diagram
The following sequence diagram shows how the add function works:
<img src="images/AddSequenceDiagram.png"/>

Choose a reason for hiding this comment

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

This diagram contains a repeated input string which is very long. Can consider mentioning the input outside of the diagram to make the diagram more compact and readable

<img src="images/FindSequenceDiagram.png" />

### Examples for Testing

Choose a reason for hiding this comment

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

Good use of examples!

#### Implementation

It implements the following operations:

Choose a reason for hiding this comment

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

Is ADDCOMMAND needed for each operation? Might want to explicitly mention that each operation belongs to ADDCOMMAND once at the start instead


`add` has seven options:
- add /id [id] /t [title] /a [author] /tag [tag] /i [isbn]
- add /id [id] /t [title] /a [author] /tag [tag] /i [isbn] _/g [genre] /s [status]_

Choose a reason for hiding this comment

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

Can consider putting these commands in a code block for readability.

Brian030601 pushed a commit to Brian030601/tp that referenced this pull request Nov 6, 2023
DavinciDelta and others added 30 commits November 14, 2023 10:35
fix bug for test
fix missed bugs
…oanneAng-PPP

# Conflicts:
#	docs/DeveloperGuide.md
Update Project Portfolio Page
# Conflicts:
#	src/test/java/seedu/commands/AddCommandTest.java
Update Project Portfolio Page
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.