Exercises

This page describes exercises connected to the course theory and assignments. The purpose is that you practice using these exercises, ask questions etc. They are a learning tool.

The Nutritionist tool

You are to develop a tool for a nutritionist. The main concept is that the user (a nutritionist) should create an plan meals for clients. Clients have goals regarding body-composition and weight, and the user should be able to track these over time.

Basic Requirements

  1. The user should be able to add, edit, delete and list clients.
  2. The user should be able to check detailed information for a selected client, this includes the meals, body composition and weight etc.
  3. The user should be able to add, edit, delete and list ingredients, with a name, price, meal type, macro nutrients, and kcal.
  4. The user should be able to add, edit, delete and list reicpes, a recipe consists of a number of ingredients, their amounts and possibly a comment, and step by step instructions.
  5. The user should be able to plan a week of recipes for a client, this includes several meals per day (breakfast, snack, lunch, dinner etc). This includes searching for suitable recipes using, name, price, meal type, kcal and/or macro nutrient contents.
  6. The user should be able to view the progress of a user for a given time period, i.e. weight, body composition, and the caloric intake. This should be shown on a weekly basis. I.e. 10 weeks are selected, the information is shown for each week.

Exercise 1 - Domain Modeling

You may do the following 3 exercises interatively, i.e. focus on a subset of the requirements and do domain model, object diagram, scenarios for that subset and then add another subset.

Exercise 1.1 - Domain Model

Create a domain model for the application.

  1. Find suitable conceptual classes
  2. Find suitable associations and refine them with names and multiplicites
  3. Find suitable attributes (no need to go over board here.)

Exercise 1.2 - Object Diagram

Create at least one object diagram that shows the domain model "in action", i.e. whith proper instances of the classes and links based on the associations.

Exercise 1.3 - Execute Scenarios

Create one or several scenarios (based on the requirments).

"Execute" the scenario over the object diagram, is the information needed present in the model? If not you may need to update the domain model and/or object diagram.

Exercise 2 - Basic Design

Exercise 2.1 Model - View - Controller - Test

  1. Create a new java project and add automatic unit tests to it. You can use for example gradle.
  2. Set up a basic MVC project structure using for example packages, or java-modules.
  3. Create two sub-packages in the Model one for domain and one for persistance
  4. Make sure everything works, by implementing a simple hello world application, you should have at least one class in every major package and also an automatic test case.

Exercise 2.2 Basic Design

  1. Pick some interesting but basic part of the application and design and implement it. Start simple: for example list clients, view client, list ingredients, view ingredient, list recipe, view recipe. Add more advanced functions as you go.

  2. Add automatic test cases as you implement

  3. Keep a class diagram updated

  4. Check your design for issues: can you make it simpler? are you using ids and not objects, hidden dependencies, magic constants? have you put are ther view/controler responsibility in the model? does the model depend on the controller or view? is there model responsibility in the view/controller? Do you have a good division between the view and controller? Is any class growing too large?

  5. If you find problems update and refine, test regularly.

  6. Create an object and sequence diagram for a specific scenario, check the implementation and make sure the diagram and implementation corresponds to eachother

  7. If still interesting, goto 1, maybe focusing on one aspect adding the add and edit requirements.

    Excercise 3 - Design Using Patterns