0% found this document useful (0 votes)
7 views

Lab #3 Class Diagrams. Domain Models Forward and Reverse Engineering

The document outlines Lab #3 objectives focused on class diagrams, domain models, and both forward and reverse engineering in UML. It includes procedures for modeling systems, creating class diagrams, and performing domain analysis for a course management system and an order system. Additionally, it emphasizes teamwork, design principles, and the application of design patterns in object-oriented analysis and design.

Uploaded by

biz.ajitesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lab #3 Class Diagrams. Domain Models Forward and Reverse Engineering

The document outlines Lab #3 objectives focused on class diagrams, domain models, and both forward and reverse engineering in UML. It includes procedures for modeling systems, creating class diagrams, and performing domain analysis for a course management system and an order system. Additionally, it emphasizes teamwork, design principles, and the application of design patterns in object-oriented analysis and design.

Uploaded by

biz.ajitesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Lab #3

Class Diagrams.
Domain Models
Forward and Reverse Engineering,

Objectives:

• Modeling systems using class diagrams.


• Creating a domain model.
• Creating class diagrams UML using modelling software.
• Getting practical experience with creating structural UML diagrams.
• Identifying classes and their associations.
• Getting practical experience on forward and reverse engineering.
• Applying design principles in OO analysis and design.
• Applying design patterns in OO analysis and design.

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

The result can be similar to:

Take a screenshot of your test class.

What design principles are applied in the code?

1.2 Use Visual Paradigm to create a class diagram.


Using the Visual Paradigm software, create a new project Lab3.
Use Tools->Code->Reverse Java Code to create a class diagram.
Take a screenshot of the diagram.
Create a new UML class diagram, drag and drop Java classes to the new diagram.
Take a screenshot of the diagram.
Describe the design pattern implemented in the Java classes.
Describe design principles applied in the system.

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.

To find the conceptual classes and create a list of conceptual classes


a. Reuse or modify an existing model
b. Use a category list
c. Identify noun phrases

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:

During a semester a lecturer reads one or more lectures.


A student usually attends one or more lectures.
During the semester there will be several labs. Each lab will cover the material from 3 lectures.
Each student is assigned to one particular group to work on labs.
Each group completes a lab report to be evaluated by calculating points.

2.1 Working with your team identify classes (A class describes a set of objects with the same
semantics, properties and behavior):

_____________________________________________________________________________
_____________________________________________________________________________

2.2 Create a new class diagram, draw classes.

Working with your team, define attributes for the classes.


Attributes are logical data values of an object.
If we do not think of some conceptual class A as a number, date or text in the real world, A is
probably a conceptual class, not an attribute.

List attributes for your classes:

_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
_____________________________________________________________________________
Add attributes to your classes in the class diagram

2.3 Working with your team, create associations.


An association is a relationship between classes. The ends of an association are called roles.
Roles optionally have a multiplicity, name and navigability.
The multiplicity defines how many instances of a class A can be associated with one instance of a
class B at any particular moment.

Add an association to the domain model if:

A is a transaction related to another transaction B


A is a line item of a transaction B
A is a product or service for a transaction B
A is a role related to a transaction B
A is physical or logical part of B.

An association class is a class attached to an association. It is used to model an association as a


UML class. It has its own name, attributes operations. However, it is described by additional
attributes which does not belong to the objects involved in the association.

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.

Take a screenshot of your analysis model class diagram.

3. Generate Java code from a class diagram using VP.


3.1 Create a new class diagram to model an Order system similar to:

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.

Discuss what operations can be added to the classes. Add operations.


Generate java code using VP tools. Take a screenshot of the generated java classes.

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.

For each class create CRC card using the template:

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:

Class name: Customer

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

5.2 Answer the following questions:

a. How do you model the following situation with a class diagram:

“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.

b. Describe where class diagrams can be used.

/1

Total Score: /10

Submit your lab report.


References:

Fakhroutdinov, Kirill. “The Unified Modeling Language.” UML Diagrams - Overview, Reference,
and Examples., www.uml-diagrams.org/.

tutorialspoint.com. “UML Tutorial.” Www.tutorialspoint.com, Tutorials Point,


www.tutorialspoint.com/uml/index.htm.

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/

You might also like