Lab #3 Class Diagrams. Domain Models Forward and Reverse Engineering
Lab #3 Class Diagrams. Domain Models Forward and Reverse Engineering
Class Diagrams.
Domain Models
Forward and Reverse Engineering,
Objectives:
Procedure:
1. Reverse Java code to class diagrams.
1.1 Start a new project in Eclipse. Name it Lab3.
Create new classes in the package strategy.
For the classes use code from the Lab 3 folder in the Moodle.
Analyze the structure of the classes and the code.
Write a TestShoppingCart class to test the processPayment method for two products added to the
cart:
upc 1234, Herschel Mens Wallet, $19.99
upc 5678, Laptop Backpack Burgundy, $48.99
Work as a group.
2. Domain Analysis. Analysis Class Diagram. Drawing a class diagram.
Domain model illustrates noteworthy concepts in a domain and identifies the set of conceptual
classes.
Part of speech
model component Examples
in a scenario
Proper noun Instance (object) Alice, Ace of Hearts
Patient, Appointment, Card,
Common noun Class (or attribute)
Customer
creates, submits, shuffles,
Doing verb Operation
calculatesTotal
Being verb Inheritance is a kind of, is one of either
Having verb Aggregation/Composition has, consists of, includes
medium (i.e. size), black (i.e.
Adjective Attribute
colour)
We will create a domain model for the following scenario for a course management system:
2.1 Working with your team identify classes (A class describes a set of objects with the same
semantics, properties and behavior):
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
Add attributes to your classes in the class diagram
Use association classes if you need to model associations which have attributes.
Add associations to your class diagram, add multiplicities, navigability, names of associations,
association classes (if needed), change the types of associations to aggregation or composition if
required.
Discuss and add attributes to classes, refine types of associations, add navigability and
multiplicities.
3.2 Use Tools->Code->Instant Generator to preview the generated java code for the class
diagram.
Use code preview to refine the class diagram. Observe java implementation of the class diagram.
4. Create an analysis model class diagram to model a part of online shopping system from
your Lab2, i.e. use case describing purchasing process (add to cart, place an order, payment).
4.1 Create CRC Cards. Identify classes, responsibilities, collaborators, specify attributes, create
associations.
Class name
(-Represents a type of object being modeled
-One card per class)
Responsibilities Collaborators
(-Something that the class knows (keeps track (-Another class that the current class has to
of) or does work with to complete its responsibilities
-High-level responsibilities. Do not list out all -Could be a class that has information we need
member functions) -Could be a class that helps perform a task)
Attributes
(named properties of a class which describes the object being modeled)
Relationships
(Association, Aggregation, Composition, Inheritance/Generalization, Realization)
Example:
Responsibilities: Collaborators:
Places ordering Order
Knows name
Knows address
Knows customerNumber
Attributes:
customerNumber: integer
name: String
address: Address
phone: String
email: String
Association: Order
4.2 Refine your UML class diagram, based on your CRC cards and team discussion:
associations (multiplicities, navigability), attributes, critical operations.
4. 3 Apply strategy pattern in the class diagram (refer to your 1.1-1.2 exercise).
Take a screenshot of your diagram.
5. Write a Lab report
5.1 Provide your work for the lab activities. Include the screenshots of the diagrams.
Reverse Java code to class diagrams (1.1 -1.2)
/3
Domain Analysis for course management system. Analysis Class Diagram. Drawing
a class diagram. (2.1 – 2.3)
/3
Domain Analysis for the Order System: refining the class diagram, generating Java
code, CRC cards for the Order System classes, improved class diagram including
strategy design pattern. (3 -4)
/3
“Every restaurant has at least one kitchen, one kitchen is part of exactly one
restaurant”. Draw two classes and correct type of association with appropriate
multiplicity.
/1
Fakhroutdinov, Kirill. “The Unified Modeling Language.” UML Diagrams - Overview, Reference,
and Examples., www.uml-diagrams.org/.
UML Distilled Third Edition: A Brief Guide to the Standard Object Modeling language by Martin
Fowler (2004).
Object-Oriented Systems Analysis and Design Using UML by Simon Bennett, Ray Farmer (2010)
System Analysis Design UML Version 2.0: an Object-Oriented Approach. Alan Dennis, Barbara
Haley Wixom, Tegarden, David, et al. Wiley, 2013.
https://creately.com/blog/diagrams/class-diagram-relationships/