-
Notifications
You must be signed in to change notification settings - Fork 89
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
base: master
Are you sure you want to change the base?
[CS2113T-W11-1] SysLib CLI #6
Conversation
…unit-tests Add JUnit tests for flashcards
There was a problem hiding this 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<>(); |
There was a problem hiding this comment.
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")) { |
There was a problem hiding this comment.
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
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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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])){ |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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{ |
There was a problem hiding this comment.
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<>(); |
There was a problem hiding this comment.
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.
docs/images/AddSequenceDiagram.png
Outdated
There was a problem hiding this comment.
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?
docs/images/AddSequenceDiagram.png
Outdated
There was a problem hiding this comment.
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
docs/images/ListSequenceDiagram.png
Outdated
There was a problem hiding this comment.
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
docs/DeveloperGuide.md
Outdated
|
||
`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]_ |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
docs/images/ListSequenceDiagram.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/images/ListSequenceDiagram.png
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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.
docs/DeveloperGuide.md
Outdated
|
||
#### Sequence Diagram | ||
|
||
<img src="images/FindSequenceDiagram.png" /> |
There was a problem hiding this comment.
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.
docs/DeveloperGuide.md
Outdated
|
||
#### Sequence Diagram | ||
The following sequence diagram shows how the add function works: | ||
<img src="images/AddSequenceDiagram.png"/> |
There was a problem hiding this comment.
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.
docs/DeveloperGuide.md
Outdated
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`. |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
docs/DeveloperGuide.md
Outdated
## Design & implementation | ||
## Setting Up & Getting Started | ||
|
||
1. Fork the repo at https://github.com/AY2324S1-CS2113T-W11-1/tp. |
There was a problem hiding this comment.
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?
docs/DeveloperGuide.md
Outdated
- `UI`: User Interaction | ||
- `Parser`: Parsing User Response | ||
- `Command`: Command Executor | ||
- `Data`: Holds the data of SysLib |
There was a problem hiding this comment.
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?
docs/DeveloperGuide.md
Outdated
- `find /id [ID]` | ||
- `find /t [TITLE]` | ||
- `find /a [AUTHOR]` | ||
- `find /i [ISBN]` |
There was a problem hiding this comment.
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.
1. Parse the filters and their associated values. | ||
2. Filter the resources based on the given filters. | ||
3. Display the matching resources. |
There was a problem hiding this comment.
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.
docs/DeveloperGuide.md
Outdated
|
||
#### 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` |
There was a problem hiding this comment.
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?
docs/images/AddSequenceDiagram.png
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
docs/images/FindSequenceDiagram.png
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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?
docs/images/ListSequenceDiagram.png
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/AboutUs.md
Outdated
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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!
docs/UserGuide.md
Outdated
____ _ _ _ ____ _ ___ | ||
/ ___| _ _ ___| | (_) |__ / ___| | |_ _| | ||
\___ \| | | / __| | | | '_ \ | | | | | | | ||
___) | |_| \__ \ |___| | |_) | | |___| |___ | | | ||
|____/ \__, |___/_____|_|_.__/ \____|_____|___| | ||
|___/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spectacular ASCII art!
docs/DeveloperGuide.md
Outdated
|
||
SysLib currently consists of four main components: | ||
|
||
- `UI`: User Interaction |
There was a problem hiding this comment.
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?
docs/DeveloperGuide.md
Outdated
### UI Component | ||
|
||
### Parser Component | ||
|
||
### Command Component | ||
|
||
|
||
### Data Component |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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… 😂
docs/DeveloperGuide.md
Outdated
|
||
#### Sequence Diagram | ||
|
||
<img src="images/FindSequenceDiagram.png" /> |
There was a problem hiding this comment.
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
docs/DeveloperGuide.md
Outdated
|
||
#### Sequence Diagram | ||
|
||
<img src="images/FindSequenceDiagram.png" /> |
There was a problem hiding this comment.
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
docs/DeveloperGuide.md
Outdated
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 | ||
____________________________________________________________ | ||
``` |
There was a problem hiding this comment.
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
- `Command`: Command Executor | ||
- `Data`: Holds the data of SysLib | ||
|
||
|
There was a problem hiding this comment.
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"/> | ||
|
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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: | ||
|
There was a problem hiding this comment.
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
docs/DeveloperGuide.md
Outdated
|
||
`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]_ |
There was a problem hiding this comment.
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.
Update Developer Guide
Created a Message.java class under UI to hold messages that are meant to be output to the user. Made minor update to DG.
Check Code Quality and Coding Standards
Update help message for edit and list
Remove unnecessary new lines and unused variables to improve neatness and quality
fix bug for test
fix missed bugs
# Conflicts: # docs/DeveloperGuide.md
…oanneAng-PPP # Conflicts: # docs/DeveloperGuide.md
Update Project Portfolio Page
# Conflicts: # src/test/java/seedu/commands/AddCommandTest.java
Update DG usecase and UG
Add More JUnit Tests
Update Project Portfolio Page
Add Syslib version printout
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.