OOAD: Data Modeling: Presenter: Dr. Ha Viet Uyen Synh
OOAD: Data Modeling: Presenter: Dr. Ha Viet Uyen Synh
CLASSES
The nouns and the verbs
Start from the requirements document;
- in function-oriented design you would
concentrate on the verbs, which correspond to actions
("do this");
- in object-oriented design you underline the
nouns, which describe objects
Example:
The elevator will close its door before it moves
to another floor.
Avoiding useless classes
The life time of an object is the most important
criteria to decide if it becomes a class or not.
Example:
Door _ the only relevant property of elevator
doors for this system is that they may be opened and
closed.
Floor _ Each floor has a floor number or some
floors may have special access rights defining who can
visit them
GENERAL HEURISTICS FOR
FINDING CLASSES
analysis classes
Class
categories
Implementat-
design classes
ion classes
Example
Analysis classes:
sensors, devices, airplanes, employees,
paychecks, tax returns, paragraphs, functions.
Implementation classes:
stack, queue, …
Design classes:
state, application, command, history-list, …
Part II
RELATIONSHIPS
Types of Relationships
Association Composition
Aggregation
Associations
Associations represent relationships between instances of
classes.
Example:
Aggregation: A company has employees. The
employees may change the company.
Composition: The company has a tax registration.
The tax registration is tied to the company and dies
with it.
Aggregation vs Composition
Some Particular Types of Classes
Generalization
Abstract Class /
Specialization
Association
Interface
Class
Association Classes
Association classes allow you to model associations
by classes, i.e., to add attributes, operations and
other features to associations
Generalization / Specialization
Generalization captures similarities between several
classes in a superclass. Specialization refines and
adds differences in subclasses.
Abstract Class
An abstract class is a class without a (full) implementation.
Some methods are deferred, i.e., they are not implemented.
The deferred methods are implemented by subclasses only.
Analysis Design
Currently-handles
0..1 *
Person Loan
address dueDate
name
0..1
Records-loan-of
1
Librarian Patron
Employs Borrows
1..* 0..1 1
*
1
1
* Resource
Library
1 Lends-resources-to callNumber
* title
Records-storage-of
1
1
Conceptual Model
Logical Model
Physical Model
Notes
1. A conceptual model is not a picture of Software
components or Classes in an object-oriented
programming language. It illustrates real-world
concepts.
The company offers docking spots for the boats. Boat owners rent
docking spots based on an annual agreement for each boat, which can
be renewed. An owner can have several boats, however each boat is
assigned a unique docking spot stated in the agreement.
North Marina also offers boat repair service which requires an owner
to sign a contract with a company representative responsible for
repair. In your class diagram, model the relationships between the
classes: DOCKING SPOT, BOAT, AGREEMENT, OWNER, CONTRACT and
REPRESENTATIVE.
hvusynh@hcmiu.edu.vn