Recipe Management System Phase 2: Design Document
Version Date Author Comments
If any corrections / clarifications are required to this document, please report them to firstname.lastname@example.org
Table of Contents
Revision History 2
1. Introduction 4
2. Requirements 5
3. Architecture 6
4. Database / Data Access Design 7
5. GUI Design 9
6. Class Diagram 15
7. Sequence Diagrams 16
8. Test Plan 17
XYZZY Software has decided to develop a recipe management system for personal use. The system must be developed using Java Technologies (NetBeans, Swing, Java DB) and a phased implementation strategy will be adopted. This document represents the current state of the design for the Phase 2 system.
Because of the simplicity of the functional requirements, the corresponding use cases are not duplicated here, as would be the case in a normal XYZZY design document.
The purpose of the system is to assist people in recipe selection. A 3 phase development process is envisaged, with the incorporation of recipe details being deferred to a later phase. In the first two phases, the selection process will be restricted to main course recipes.
A Java desktop application is to be developed, driven by a simple Swing GUI. Interaction between the database and the application is to be via JDBC. The NetBeans IDE is to be used for development. Java DB must be used as the database.
The functional requirements for the Phase 1 system were as follows:
1. Start the application and connect to the database
2. Close the database connection and stop the application
3. Display all recipes for a particular category (meat, fish, vegetarian)
4. Display all recipes for a particular category with a preparation time within a specified range
5. Display all recipes for a particular category with a combined preparation and cooking time that is within a specified range
6. Display the number of recipes that have a specified ingredient as its key ingredient
7. Add a new recipe to the database.
8. Clear the display
In addition, the application had to conform to the MVP architecture. In Phase 2, the application is to be refactored to conform to the MVC architecture. Also, an additional requirement has been added:
9. The output from the queries that return recipes is to be browsable and browsing is to be cyclic.
The database design and sample data are provided in Section 4. Data validation is not required at this stage. However, basic preconditions must be satisfied for each requirement and if these are not satisfied, an appropriate message is to be displayed. These preconditions are specified in Section 8.
An MVP conformant three-layered architecture is to be used for the application. Layers are to be modelled as packages – the package structure for the application is illustrated in Figure 1.
Figure 1. Package structure
4. Database / Data Access Design
The SQL script that is to be used to create the database’s RECIPES table is given below.
DROP TABLE RECIPES;
CREATE TABLE RECIPES
ID INT NOT NULL GENERATED ALWAYS AS IDENTITY,
RECIPENAME VARCHAR (60) NOT NULL,
CATEGORY VARCHAR (10) NOT NULL,
MAININGREDIENT VARCHAR (10) NOT NULL,
PREPARATIONTIME INT NOT NULL,
COOKINGTIME INT NOT NULL
INSERT INTO RECIPES (RECIPENAME,CATEGORY,MAININGREDIENT,PREPARATIONTIME,COOKINGTIME)
('fish and chips','fish','fish',5,10),
('grilled steak and salad','meat','steak',15,5),
('baked beans on toast','vegetarian','beans',0,5);
As there is only one table, an ERD is not provided.
Data access will be via JDBC using prepared statements. Java DB must be used as the database.
Normally, in an XYZZY design document, we would specify the queries in this section and relate them to the methods exposed by the RecipesQueries class described in Section 6. However, for this project, we have decided to leave query formulation to the implementers. Note that if you choose to use SQL’s COUNT() method for Requirement 6, the result set returned when the query is executed consists of a single row with a single column that contains an int. To retrieve this value, use code similar to the following:
// execute query here
// resultSet and n have been declared elsewhere
n = resultSet.getInt( 1 );
5. GUI Design
Developers are free to use the NetBeans GUI Builder or alternatively, they can hand code the complete GUI. An indicative GUI is presented in Figure 2 and Table 1. Developers are free to use this design as is or to do things differently, for example using menus for data entry. The required actions for each requirement are summarised in Table 2.
Figure 2. Indicative GUI
Functionality Swing Components
Input JLabel, JTextField
Table 1. Mapping of GUI functionality to Swing component types.
Requirement Button Inputs Required
1 n/a n/a
2 Exit None
3 Category Category
4 Category and Preparation Time Category and Preparation times – see below
5 Category and Combined Time Category and Combined Times – see below
6 Main Ingredient Main Ingredient
7 Add All, except for right-most Preparation and Cooking times and Combined Times
8 Clear n/a
9 Previous, Next n/a
Table 2. Mapping of requirements to actions
For Requirements 4 and 5, note that clicking of the corresponding button will result in the invocation of a single method.
If two numbers are specified as input, then they are to be treated as the lower bound (left) and upper bound (right) of an inclusive range. Having the upper bound less than the lower bound is to be treated as an error. Having both numbers the same is not an error – they are the endpoints of a range of length zero.
If one number is specified, then if it is the right input, then the left input is set to 0. If the left input is specified, then the right input is set to the value of the left input.
Validation of inputs is to be done in the RecipesView class.
Note that in this version, if a query returns a list of recipes, then that list is to be browsable using the previous and next buttons with output appearing in the appropriate input text fields, as in the Address Book case study. The text area is still used but only for the display of error messages, status messages and the output of non-query commands, such as Add. Example screen shots are shown below:
Figure 3. Example display after Category selected for “meat”
Figure 4. Example display after Next button clicked
Figure 5. Example display after Category selected for “veg” (no records)
Figure 6. Example display after new recipe added.
6. Class Diagram
The class diagram for the application is illustrated in Figure 3.
Figure 3. Class diagram
The mapping to packages/layers is provided in Section 3. Note that Figure 3 represents a refactoring of the class structure favoured by the NetBeans GUI Builder. Rather than having GUI creation in the GUI class definition (through the provision of a main() method, we have chosen to place GUI creation in a separate main class. If you are using the NetBeans GUI builder, all that this means is that the main() method that the Builder generates is moved into the Recipes class. Also note that interaction between the RecipeQueries class and the JBC library classes is not shown. This is normal for class diagrams. Finally, formal UML syntax is not strictly followed. In particular, we feel felt that method signatures as employed in NetBeans are clearer than their UML counterparts.
7. Sequence Diagrams
8. Test Plan
The following tests will be performed prior to acceptance:
Requirement Test Comment
1 Operation performs correctly given correct preconditions
1 Handles no database/incorrect database Application is to exit
2 Operation performs correctly
3 Operation performs correctly given correct preconditions
3 Handles incomplete field entry
4 Operation performs correctly given correct preconditions No data validation checks required.
4 Handles incomplete field entry
4 Input variants as specified in Section 5 are handled correctly
5 Operation performs correctly given correct preconditions No data validation checks required.
5 Handles incomplete field entry
5 Input variants as specified in Section 5 are handled correctly
6 Operation performs correctly given correct preconditions No data validation checks required.
6 Handles incomplete field entry
7 Operation performs correctly given correct preconditions No data validation checks required.
7 Handles incomplete field entry
8 Display is cleared Note that only the view is cleared
9 Browsing is cyclic
Table 3. Acceptance tests
1. By preconditions, we mean that the required values are available.
2. Acceptance tests coincide with class unit tests, so no separate unit testing is required.
3. Testing will be conducted with the database specified in Section 4.