Skip to content

[CS2113-F14-4] EZMealPlan#44

Open
Teng-Yong-Quan wants to merge 571 commits into
nus-cs2113-AY2425S2:masterfrom
AY2425S2-CS2113-F14-4:master
Open

[CS2113-F14-4] EZMealPlan#44
Teng-Yong-Quan wants to merge 571 commits into
nus-cs2113-AY2425S2:masterfrom
AY2425S2-CS2113-F14-4:master

Conversation

@Teng-Yong-Quan
Copy link
Copy Markdown

EZMealPlan helps busy people with food dilemma and meal-preparation issues to suggest food recommendations for them. It uses a simple-to-use CLI to provide meal suggestions to the users, taking into account their budget, food preferences and the ingredients they have.

rchlai added a commit to rchlai/tp that referenced this pull request Mar 20, 2025
Merge branch 'master' into branch-rchlai
Copy link
Copy Markdown

@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.

Good work thus far! Just some minor suggestions on your coding standards and quality. Keep up the good work!

*/
public Meal removeMeal(int index) throws EZMealPlanException {
try {
return mealList.remove(index - 1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe it would be good to comment why it is index - 1 to make it more understandable

int indexOfIndex = 1;

try {
return input.split("\\s+")[indexOfIndex];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe it would be good to refactor the regex to make it more understandable to readers and to avoid magic strings

Comment on lines +71 to +87
if (file.exists()) {
Scanner scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim();
if (line.isEmpty()) {
continue;
}
// Split the line by "|" with optional spaces around it.
String[] parts = line.split("\\s*\\|\\s*");
int minLengthToHaveIng = 2;
if (parts.length < minLengthToHaveIng) {
continue; // Skip lines that don't have ingredients.
}
checkValidMeal(parts, meals);
}
scanner.close();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe to reduce the nesting you can look into using a guard clause:

if (!file.exists()) {
  return meals;
}
// if file exists

}
// Split the line by "|" with optional spaces around it.
String[] parts = line.split("\\s*\\|\\s*");
int minLengthToHaveIng = 2;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe this can be placed as a constant instead?

int openBracketIndex = ingredientStr.indexOf("(");
int closeBracketIndex = ingredientStr.indexOf(")");
int notFoundIndex = -1;
if (openBracketIndex == notFoundIndex || closeBracketIndex == notFoundIndex) {
Copy link
Copy Markdown

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 expression within the if statement to be a simpler expression.

return;
}
switch(commandDescription) {
case "list":
Copy link
Copy Markdown

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 avoid magic strings

Comment on lines +108 to +109
String splitRegex = "\\s*,\\s*";
String[] ingredientsArray = ingInput.split(splitRegex);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good work here refactoring the magic string regex, do make it consistent for the rest of the project!

Comment on lines +18 to +24
String ing = "/ing";
String mname = "/mname";
String mcost = "/mcost";
String filterMethod = "";
final String byIng = "byIng";
final String byMname = "byMname";
final String byMcost = "byMcost";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good work on refactoring the magic strings! But maybe since it is a constant, its naming could be in SCREAMING_SNAKE_CASE.

Comment thread docs/ListCommand.png
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Might be worth moving images into a folder ie docs/imgs, nbd tho

Comment thread docs/img.png Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

very nice diagrams

Comment thread docs/DeveloperGuide.md Outdated
assertIterableEquals(expectedMeals, testUI.capturedMeals);
}
```
## Implementation
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could write this part or remove redundant title

Comment thread docs/DeveloperGuide.md Outdated
|Version| As a ... | I want to ... | So that I can ...|
|--------|----------|---------------|------------------|
|v1.0|new user|see usage instructions|refer to them when I forget how to use the application|
|v2.0|user|find a to-do item by name|locate a to-do without having to go through the entire list|
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe just attatch this part to the bottom of the above table, since you have a column for version it would be redundant if every version is a separate table

Copy link
Copy Markdown

@jxromy jxromy left a comment

Choose a reason for hiding this comment

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

Reviewed your UML diagrams and syntax, overall a well-written DG :)

Comment thread docs/DeveloperGuide.md Outdated
|Version| As a ... | I want to ... | So that I can ...|
|--------|----------|---------------|------------------|
|v1.0|new user|see usage instructions|refer to them when I forget how to use the application|
|v2.0|user|find a to-do item by name|locate a to-do without having to go through the entire list|
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

User stories for v1.0 looks good! perhaps more can be added to v2.0?

Comment thread docs/DeveloperGuide.md
![ConstructingMainMeals.png](diagrams/ConstructingMainMeals.png)
This sequence diagram shows the procedures of extracting meals from the "mainMealFile" (mainList.txt). The procedures of extracting meals from the "userMealFile" (userList.txt) can be depicted simply by replacing "mainMealFile" with "userMealFile", storage.getMainListFile() with storage.getUserListFile(), mealManager.getMainMeals() with mealManager.getUserMeals() and lastly, "mainMeals" of MainMeals class with "userMeals" of UserMeals class.

![RunCommandSequenceDiagram.png](diagrams/RunCommandSequenceDiagram.png)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great diagram! I love the use of different colours

Comment thread docs/DeveloperGuide.md

- All user inputs are case-sensitive and normalised to lowercase.

![BootingUpEZMealPlan.png](diagrams/BootingUpEZMealPlan.png)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Activation boxes are clearly shown and program flow is depicted well

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

New line error in text after diagrams in this section

Comment thread docs/DeveloperGuide.md Outdated
![BootingUpEZMealPlan.png](diagrams/BootingUpEZMealPlan.png)
This sequence diagram shows the processes that EZMealPlan system has to undergo while it is being booted up before it is ready for usage.

![ConstructingMainMeals.png](diagrams/ConstructingMainMeals.png)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Perhaps a High-Level Architecture Diagram would help to illustrate how major components interact (e.g., Parser → Command → MealManager → Storage)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree with this statement as the diagram would illustrate the relationship between each componenets as well

Copy link
Copy Markdown

@wongyihao02 wongyihao02 left a comment

Choose a reason for hiding this comment

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

generally looks good

*
* @param ingredients a list of ingredients (with name and price) to be bought.
*/
public BuyCommand(List<Ingredient> ingredients) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

dont see this command in the Dev guide.Where does this fit?Is this for constructing meals?

public abstract class FilterSelectCommand extends Command {
String filterOrSelect;
String ing = "/ing";
String mname = "/mname";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why arent these final,dosent seem like they are getting changed in this class.

ui.printDeleteCommandHelp();
break;
case "view":
ui.printViewCommandHelp();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

good that code is being abstracted out,SLAP

logger.fine("exiting EZMealPlan");
}

private static void checkConstructedLists(MealManager mealManager) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

could these commands be abstracted out into their own classes/packages?

Copy link
Copy Markdown

@TiangSoonYong TiangSoonYong left a comment

Choose a reason for hiding this comment

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

Overall the UML diagrams are well constructed and readable. One minor issue is regarding the use of PNGs instead of the PUML itself.

Comment thread docs/diagrams/Food.png
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It is mentioned that Product is an Abstract, perhaps it should be reflected here as well. Maybe you could change the diagonal arrows to vertical arrows instead as it affected the readability of the multiplicity of ingredientList.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I like the use of colours within the diagram and it make it more readable!

Comment thread docs/DeveloperGuide.md Outdated
![BootingUpEZMealPlan.png](diagrams/BootingUpEZMealPlan.png)
This sequence diagram shows the processes that EZMealPlan system has to undergo while it is being booted up before it is ready for usage.

![ConstructingMainMeals.png](diagrams/ConstructingMainMeals.png)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree with this statement as the diagram would illustrate the relationship between each componenets as well

Comment thread docs/DeveloperGuide.md Outdated
- **Storage**: Handles saving and loading from `main_meal_list.txt` and `user_meal_list.txt`.

{Describe the target user profile}
### Logging
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Logging section may need some more expanding on

Comment thread docs/DeveloperGuide.md

**Testability:**
- The design allows for easy unit testing by injecting a test-specific UI that captures the output.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Design goals are well explained

Comment thread docs/DeveloperGuide.md Outdated
| v1.0 | Time-constrained user | Check for recipes based on cook time | Quickly find recipes for myself |
| v1.0 | Social user | Share my favorite recipes with friends | Get feedback from friends or cooks |
| v1.0 | new user | see usage instructions | refer to them when I forget how to use the application |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

user stories are well thought out and contains many considerations for the user

Comment thread docs/DeveloperGuide.md Outdated
assertIterableEquals(expectedMeals, testUI.capturedMeals);
}
```
## Implementation
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The implementation may need to be worked on, with the sequence diagrams added here

Comment thread docs/DeveloperGuide.md
![ConstructingMainMeals.png](diagrams/ConstructingMainMeals.png)
This sequence diagram shows the procedures of extracting meals from the "mainMealFile" (mainList.txt). The procedures of extracting meals from the "userMealFile" (userList.txt) can be depicted simply by replacing "mainMealFile" with "userMealFile", storage.getMainListFile() with storage.getUserListFile(), mealManager.getMainMeals() with mealManager.getUserMeals() and lastly, "mainMeals" of MainMeals class with "userMeals" of UserMeals class.

![RunCommandSequenceDiagram.png](diagrams/RunCommandSequenceDiagram.png)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well drawn diagram! The colour coding made it easier to read.

Comment thread docs/DeveloperGuide.md Outdated

##### 1.3 Sequence Diagram

![.\diagrams\MealCommand.png](.\diagrams\MealCommand.png)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The return lines should be dashed instead of solid

olsonwangyj and others added 30 commits April 8, 2025 12:09
Update UML and correct typos in UG
update DG with for consume and checker
…into branch-final-refactoring

# Conflicts:
#	src/main/java/ezmealplan/command/RecommendCommand.java
…into branch-final-refactoring

# Conflicts:
#	src/test/java/ezmealplan/command/RecommendCommandTest.java
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.