[CS2113T-W11-1] SysLib CLI#6
Conversation
…unit-tests Add JUnit tests for flashcards
|
|
||
| public class Parser { | ||
|
|
||
| public List<Resource> resourceList = new ArrayList<>(); |
There was a problem hiding this comment.
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.
"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.
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.
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.
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.
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.
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.
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.
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.
Plural form should be used on names representing a collection of objects.
There was a problem hiding this comment.
would it be better for the arrow in the condition where containsKey is false to show some kind of exception being invoked?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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]_ |
There was a problem hiding this comment.
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.
antrikshdhand
left a comment
There was a problem hiding this comment.
Overall a nice DG, however the verbose sequence diagrams could be improved.
|
|
||
| #### Sequence Diagram | ||
|
|
||
| <img src="images/FindSequenceDiagram.png" /> |
There was a problem hiding this comment.
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"/> |
There was a problem hiding this comment.
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.
| 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.
A well-written, detailed explanation of the process. Great for a future developer!
| ## 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.
Would it be better to use hyperlinks?
| - `UI`: User Interaction | ||
| - `Parser`: Parsing User Response | ||
| - `Command`: Command Executor | ||
| - `Data`: Holds the data of SysLib |
There was a problem hiding this comment.
Would it be better to indicate where other packages (e.g., storage, common, etc.) belong?
| - `find /id [ID]` | ||
| - `find /t [TITLE]` | ||
| - `find /a [AUTHOR]` | ||
| - `find /i [ISBN]` |
There was a problem hiding this comment.
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.
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` |
There was a problem hiding this comment.
Why is "Step 1." in bold above but not here? Is it better to have a unified style?
There was a problem hiding this comment.
This picture is too wide! Try to avoid repeating the parameters that are too long.
There was a problem hiding this comment.
One activation bar corresponds to one method call. Therefore :Command should have 2 activation bars.
There was a problem hiding this comment.
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.
Would it be more accurate to explicitly mark :AddCommand as destroyed?
There was a problem hiding this comment.
One activation bar corresponds to one method call. Therefore :Command should have 2 activation bars.
There was a problem hiding this comment.
Would it be more accurate to use -> instead of --> for the arrow of warning?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
One activation bar corresponds to one method call. Therefore :Command should have 2 activation bars.
There was a problem hiding this comment.
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.
The avatars are too big! Maybe making the picture smaller will look better!
| ____ _ _ _ ____ _ ___ | ||
| / ___| _ _ ___| | (_) |__ / ___| | |_ _| | ||
| \___ \| | | / __| | | | '_ \ | | | | | | | ||
| ___) | |_| \__ \ |___| | |_) | | |___| |___ | | | ||
| |____/ \__, |___/_____|_|_.__/ \____|_____|___| | ||
| |___/ |
|
|
||
| SysLib currently consists of four main components: | ||
|
|
||
| - `UI`: User Interaction |
| ### UI Component | ||
|
|
||
| ### Parser Component | ||
|
|
||
| ### Command Component | ||
|
|
||
|
|
||
| ### Data Component |
There was a problem hiding this comment.
Maybe can add some content after each title
There was a problem hiding this comment.
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" /> |
There was a problem hiding this comment.
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" /> |
There was a problem hiding this comment.
if you are calling a function resourceList should be like resourceList() in the sequence diagram
| 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 | ||
| ____________________________________________________________ | ||
| ``` |
| - `Command`: Command Executor | ||
| - `Data`: Holds the data of SysLib | ||
|
|
||
|
|
There was a problem hiding this comment.
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.
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 | ||
|
|
| #### Implementation | ||
|
|
||
| It implements the following operations: | ||
|
|
There was a problem hiding this comment.
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]_ |
There was a problem hiding this comment.
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.