Developer Guide - Diet Manager

Content

  1. Design
    1. Architecture
    2. UI component
    3. Storage component
    4. Logic component
    5. Model component
    6. Commons component
  2. Implementation
    1. Launch Application
    2. Logic Management
    3. Record Meal Feature
  3. Product Scope
    1. Target user profile
    2. Value proposition
  4. User Stories
  5. Non-Functional Requirements
  6. Glossary
  7. Instructions for Manual Testing

Design

Architecture

ArchitectureDiagram

The Architecture Diagram given above explains the high-level design of the Diet Manager Application.

The components involved are given below:

UI component

UI-Component

The UI component is responsible for:

The UI consists of the following classes:

The UI component

  1. Reads user input and passes it to Logic for parsing and execution of the command.
  2. Receives command results from Logic and listens for changes in Model to display updated information to the user.
  3. Draws on Commons to obtain the relevant messages to be displayed to the user.

Storage component

Storage-Component

The Storage component is responsible for:

The Storage consists of the following classes:

The Storage component

  1. Reads data files (if present) using Logic and updates Model with the relevant information during start up.
  2. Receives instructions from logic to save and write in-memory information from Model into the relevant data files.

Logic component

Logic-Component

The Logic component is responsible for:

The Logic consists of the following classes:

The Logic component

  1. Receives the user input and parses it to generate a specific command.
  2. Executes the command to generate a specific result.
  3. Passes results to UI to display system output to the user.
  4. Updates Storage to save any changes made to in-memory information to the respective data files.

Model component

Model-Component

The Model component is responsible for:

The Model consists of the following classes:

The Model component

  1. Receives instructions from Logic to update in-memory information.
  2. Is not dependent on any of the other components.
  3. Contains all the classes that are responsible for database and records of food and user

Commons component

The Commons component is responsible for:

The Commons consists of the following classes:

Implementation

Launch Application

Launch Application

Implementation

Upon startup of Diet Manager:

  1. AppManager.launch() is called.
  2. AppManager then constructs the relevant object required for the application to function. These objects include, in the order of construction:
    • UI - User Interface functions
    • LogsCentre - Logging and system tracking functions
    • Profile - Holds user profile data in-memory
    • FoodNutritionRecord - Holds food nutrition data in-memory
    • Storage - Prepares data files for reading, writing and saving of information
  3. Once the objects have been created, Storage then loads any current data from data files (if any) into local memory for the application to access. If no data files are found, Storage creates new data files for future storage.
  4. All relevant components have now been initialised and the application is ready to be run.

Design and Enhancements

The modular system of initialising the application serves several purposes:

  1. Reducing coupling and dependence between essential components upon startup
  2. Aid in debugging by isolating the components
  3. Future enhancements which might include the construction of additional components

This implementation can be further enhanced by further abstracting initialisation of different components, which would be useful in the future when more components are added to enhance this application.

Logic Management

Logic Flow

Implementation

The logic flow of DietManager was intentionally made to be modular in design, and allow AppManager to be the sole handler of all logic-based executions.

Upon running the application:

  1. A check is done for the ui.exitStatus() of the application, and exits the loop if the user entered the exit command during the previous iteration.
  2. UI calls readInput() to read in user input.
  3. The String value of user input then gets passed back to AppManager.
  4. The String value then gets parsed through CommandParser to generate a specific Command.
  5. This command will then be passed back to AppManager.
  6. AppManager checks if the command is valid using isCommandValid().
  7. If the command is valid, AppManger executes the command using execute().
  8. The command Result then gets returned to AppManager, where it will be displayed to the user.
  9. The loop then continues, from steps 1 to 9.
  10. If the user exits the application, the application will terminate and all created components will be destroyed.

Design and Enhancements

The modular system of running the application serves several purposes:

  1. Reducing coupling and dependence between essential components upon startup
  2. Aid in debugging by isolating the components
  3. Future enhancements which might include the construction of additional components

The design of AppManager was done to prevent the possibility of errors occurring in multiple components due to potential bugs, and narrows down the scope of potentially flawed components.

This aids in testing and debugging of the application, as well as leaves space for future enhancements, by allowing other components to interact with the application without having to change multiple different components to achieve this. This allows for greater accessibility and modularity.

This implementation can be further enhanced by abstracting the logic flow of different components into separate classes. Thus each individual class will be responsible for the logic management of a particular component thus would allow for more modularity, testability and expandability.

Record Meal Feature

Implementation

The record feature is facilitated by RecordMealCommand. It extends Command and overrides execute() and saveResults()

Given below is an example usage scenario and how the record mechanism behaves at each step.

Step 1. The ui object gets user input and sends it to the parser. The parser then parses the original input into a standard command and returns it. The command type is decided by the commandPrompt. The RecordMealCommand has record-meal as its commandPrompt. During the process a newRecordMealCommand object will be generated and returned to the Logic component.

Step1. Generate command

Step1. Diagram

Step 2. The Logic composition calls the execute() method of the RecordMealCommand object.

During the process of execution, the command object will generate a ArrayList<Food> foodList, which maintains all Food items listed in the user input. If a certain kind of Food can be found in the database of FoodNuritionInfo, then this food item will be fetched from the database. Else a new Food object will be generated simply with foodName without all the nutrition info.

During execution, the command object will try to get a record object of the class DailyFoodRecord. The date of record is specified by the user. If no record of that day is found in profile, it will automatically generate a new record of the day. Then with foodList and record, can call the method record.recordMeals().

Step2. Execute and Save Result

Step2. Diagram

Design Considerations

Aspect: How RecordMealCommand executes and save results

Aspect: Data structure to support the command

Product Scope

Target user profile

Students that :

  1. are too busy with schoolwork to carefully monitor their eating habits
  2. are concerned about their health
  3. likes to keep track of their meals/weight habit digitally
  4. want to keep track of their weight

Value proposition

Diet Manager aims to achieve the following:

  1. Streamline the diet recording and monitoring process
  2. Allow users to track food calories intake and monitor their eating habits
  3. Enable users to monitor weight changes over time and work towards their ideal weight goal
  4. Provide personalised health information and dietary recommendations for the user
  5. Monitor and track user’s weight changes to achieve weight goal
  6. Check their BMI as well against the BMI table regardless of user

User Stories

Version As a … I want to … So that I …
v1.0 student set a profile with personal information receive personalised information regarding my diet
v1.0 student record my calories intake can keep track of my total calorie intake for the week effectively
v1.0 student record my food intake see what I ate today
v1.0 student see my diet history can track my diet and maintain a balanced and healthy diet lifestyle
v1.0 student set a weight-goal received feedback on progress regarding my weight goal
v1.1 student record my weight changes can see if i am doing well towards my expectation
v1.1 student check nutritional values of certain foods can check how much calories i am consuming
v1.1 student check if I am keeping to my recommended caloric intake do not over or under eat and maintain my diet
v1.1 student add food items to the database do not have to constantly check food nutritional value for common foods
v1.2 student save my diet history have a record of my daily food intake
v1.2 student save my profile do not have to constantly set a new profile
v1.2 student import my diet history have access to previous records and be able to progress from there
v1.2 student receive dietary advice based on my excess calorie intake for the day can maintain my calories for the day
v1.2 student export my diet history can view my previous records on other devices and never ever lose my progress
v2.0 student generate a recommended food plan know what to eat to meet recommended caloric intake
v2.0 student save and export my food plan print it out or bring it with me

Non-Functional Requirements

Device Environment:

Performance:

Reliability:

Glossary

Instructions for Manual Testing

For manual testing, developers can follow the instructions listed out in the UserGuide

Alternatively, they can also follow the following steps to test out the respective commands, upon downloading the jar file, while adhering to the specified restrictions in Glossary:

  1. set-profile NAME AGE GENDER HEIGHT WEIGHT WEIGHTGOAL
    • Creates a new profile
  2. profile
    • View user profile details
  3. set-name NAME
    • Update name in profile.
  4. set-age AGE
    • Update age in profile.
  5. set-age GENDER
    • Update gender in profile.
  6. set-height HEIGHT
    • Update height in profile.
  7. set-weight-goal WEIGHT-GOAL
    • Update weight-goal in profile.
  8. set-weight WEIGHT
    • Update weight in profile.
  9. delete-weight INDEX
    • Delete a specific weight record.
  10. check-weight-progress
    • Check user weight record progression.
  11. check-bmi
    • Check user BMI and BMI classification.
  12. record-meal DATE TIMEPERIOD /FOOD1 {-- 10.0} /FOOD2 {-- 6.00} /...
    • Record a meal
  13. check-meal DATE TIMEPERIOD
    • Check a meal
  14. clear-records
    • Clear all food records
  15. check-required-cal DATE ACTIVITYLEVEL
    • Check calories required based on user’s activity level
  16. calculate {DATE1}->{DATE2}
    • Calculates calories intake on a day or during a time period
  17. list-food
    • List all foods recorded in the database
  18. addf FOODNAME --CALORIES
    • Add a new food into database
  19. delf FOODNAME
    • Delete a food from the database
  20. new-recipe MAXIMUM_FODD_TYPES ACTIVITY_LEVEL
    • Create a recommended recipe for user
  21. show-recipe
    • Show the recipe recommended for user
  22. help
    • Show the help function table with supported commands.
  23. exit
    • Terminates and exits the application.

Click here to go back to the main page.