KIT206 Tutorial 3 – Class diagrams from structured scenarios
KIT206 Software Design & Development KIT506 Software Application Design & Implementation
1/3
Tutorial 3: Class diagrams from structured scenarios
Purpose: To make further progress on structured scenarios for the Human Resource Information
System (HRIS) and then use them to derive a class diagram for part of the HRIS.
Outline
In today’s exercises you’ll build upon the skills you developed last week to begin creating a class
diagram for part of the HRIS using the information available in the structured scenarios you’ve
prepared. You’ll still be focussing on the entities, but you will likely identify the need for other kinds
of object to manage those entities (load them from a database, sort them, filter them, search them).
You will also start to impose a logical structure on the classes in your model by placing them in
packages.
0 Preparation
If you haven’t already:
• form a group of three for Assignment 1 (each member must enrol in the same group on MyLO);
• read the requirements document and RTM for the HRIS.
1 Complete some more structured scenarios (< 40 minutes) Task: Extend your current work on structured scenarios for the HRIS so that you have draft structured scenarios for at least use cases 8, 16, 23, and 24. If you’ve made some progress on the nice-to-have use cases 19, 28, and 37 then that’s good, but they will most likely be useful when identifying custom GUI components and other necessary behind-the-scenes classes and their operations, which you will add to your OO model later. These structured scenarios, even if not yet complete, will give you a good starting point for developing the static object-oriented model for the HRIS. Once you have the drafts ready, consider the following: what classes (types of object) can you identify? What are their attributes? Are there any obvious operations, perhaps described as derived or calculated data? Do the scenarios you’ve created indicate any relationships between classes? 2 Preparing a StarUML project for the HRIS Unlike the model you created last week, your model for the HRIS will use packages to logically organise the different classes of object, so you’ll do a little more preparation to give your project structure. Task: Start StarUML and do the following to prepare the untitled project for your HRIS model: 1. Select the Untitled model root in the Model Explorer and rename it to something like ‘HRIS’, and rename the Model node beneath it to something like ‘HRIS models’. 2. Delete the Main class diagram that StarUML creates by default; you will create class diagrams inside packages, which are themselves parts of a package diagram. 3. From the context menu on the model node you just renamed, select Add Diagram… | Package Diagram, and rename it to ‘Packages’. 4. Select and open the package diagram and then add a Package symbol to the diagram editing window. Name this ‘Model’, ‘Entity’ or some other name that indicates that it will contain some of the entity classes in the system. (In your assignment submission you will give this a more descriptive name.) KIT206 Software Design & Development KIT506 Software Application Design & Implementation 2/3 5. Right-click the new package’s entry in the Model Explorer and select Add Diagram… | Class Diagram. This will create a class diagram for the classes within this package. 6. Remember to save the project with a suitable name. It will resemble the following image. 3 Creating a class diagram Task: Working in the class diagram for the Model (or Entity, etc.) package you created above, and based on whichever scenarios you have developed so far, create a class diagram that represents some of the different entities involved in those use cases. Module 2, part 2 contains some heuristics (guidelines) for extracting classes and their operations based on the information in a scenario. It’s not essential that you identify any operations at this stage (unless they are obvious), and you needn’t complete the list of each class’s attributes right now either (since there is another task in the tutorial). Your focus should be on creating a class structure that best represents the objects and their relationships. Concentrate on the entity objects, but you may also wish to include some boundary (GUI) and control objects (responsible for interacting with the data classes in response to user events), if they are implied by the scenario. Eventually these will go in different packages. You will refine the model later as you work on the assignment. 3.1 Additional tips for modelling classes with StarUML Remember that: • you can create new Enumeration data types when an attribute can only take on a small set of predefined values; and • you can modify the end points of an association to indicate the number (multiplicity) of one type of object relative to the other and whether the association is navigable (whether both or only one side knows about the other; double-click the end you want to change. KIT206 Software Design & Development KIT506 Software Application Design & Implementation 3/3 You can also do the following in StarUML and many other UML modelling tools: • To change which package a class belongs to, drag it in the Model Explorer. • As you start arranging your classes into different packages, whenever you need to show a relationship between a class in the current package and one in another you can drag that class from the Model Explorer into your current diagram. Note that you don’t have to do this in both directions: some general purpose classes may be used by lots of other classes, so could be imported into those models, but the classes doing the using don’t have to appear in the original class diagram where the general purpose class is. Note that while many UML tools present an imported class’s name as PackageName::ClassName, StarUML 2 includes this as a parenthetic comment (from PackageName). 4 Next week: sequence diagrams If you have time and would like to begin modelling dynamic features of the system, then in the Model Explorer add a Sequence Diagram to your HRIS model. This will create three new nested elements in the model. Name the actual sequence diagram ‘UC8_User_views_StaffList’ (and rename Interaction1 to match), and rename Collaboration1 to ‘Sequence diagrams’. You can add additional sequence diagrams to this ‘Collaboration’ entry in the model tree. Outline 0 Preparation 1 Complete some more structured scenarios (< 40 minutes) 2 Preparing a StarUML project for the HRIS 3 Creating a class diagram 3.1 Additional tips for modelling classes with StarUML 4 Next week: sequence diagrams