Week 9 Class Diagram1
Week 9 Class Diagram1
Week 9 Class Diagram1
(Professional Solutions)
.
Week 9 : Class Diagram
Dr Azida Zainol
Subject Group Computer Science & Software
Engineering
Email : [email protected]
Objectives
• Understand UML notations for conceptual data modeling.
• Explain relationship characteristics such as degree and
multiplicity.
• Describe data relationships such as association,
aggregation, and generalization.
• Develop class diagram
2
What Is a Conceptual Data Model?
• A detailed model that shows the overall structure of organizational
data; it is independent of any database management system or other
implementation considerations.
3
Class diagram
• A class diagram shows a set of classes, interfaces and collaborations
and their relationships
• It models the static design view of a system
• Important for visualisation, specifying and documenting structural
models for constructing executable system
4
Uses of a class diagram
• To model the vocabulary of the system
• What fall under a system and its responsibilities
• To model simple collaborations
• To model the logical database scheme
5
Conceptual Data Model Elements
6
1. Object/Class
• An entity that encapsulates data and behavior
Instances
8
UML Class symbol
has three parts:
1) Name
2) List of attributes
3) List of
operations
9
Class Symbol
Client
Class name
compartment - companyAddress private
- companyEmail
Attributes - companyFax public
+ companyName
compartment
# companyTelephone
Operations + getClientInfo( )
protected
compartment - updateClientInfo( )
10
Class > Stereotypes
• Stereotype – a construct that extends the UML vocabulary
• Analysis class stereotypes differentiate the roles objects can play:
1. Boundary/Interface objects model interaction between the system and
actors (and other systems)
2. Entity objects represent information and behaviour in the application
domain
3. Control objects co-ordinate and control other objects
11
Class > Stereotypes
startInterface( ) startInterface( )
assignStaff( ) assignStaff( )
selectClient( ) User Interface::AddAdvertUI
selectClient( )
selectCampaign( ) selectCampaign( )
12
Class > Stereotypes
title title
campaignStartDate campaignStartDate
campaignFinishDate campaignFinishDate
Campaign
getCampaignAdverts( ) getCampaignAdverts( )
addNewAdvert( ) addNewAdvert( )
13
Class > Stereotypes
<<control>>
Control::AddAdvert
Control::AddAdvert
showClientCampaigns( )
showClientCampaigns( )
showCampaignAdverts( )
showCampaignAdverts( ) AddAvert
createNewAdvert( )
createNewAdvert( )
14
Class Diagram: Instance Symbol
Instances do not
have operations
15
2. Attributes
Attributes are:
• Part of the essential description of a class
• The common structure of what the class can ‘know’
• Each object has its own value for each attribute in its class
16
Types of attributes
17
Attribute Stereotypes in Class Diagrams
• Stereotype – a construct that extends the UML vocabulary
• Identifier stereotype <<PK>> for primary key
• Multivalued stereotype <<multivalued>>
18
Primary key is a
unique identifier;
no two Student
instances will
have the same
studentId value.
19
Multi valued
attribute can
contain multiple
values; a student
may have several
phone numbers
20
• Composite attributes have multiple sections (sub
attributes).
• They are treated as separate classes in conceptual
data models.
21
3. Relationship
• A semantic connection between objects of one or
more classes
• In UML, represented as a line connecting two or
more class boxes (or connecting one class to itself)
• Relationships including : association, generalization,
dependency and realization. (UML Ref Manual,1999)
• Association: provide the connections with which
objects of different classes can interact.
22
Roles identify the purpose of each class in the
relationship.
23
Relationship: Associations
Association name
Direction in which
name should be read
24
Relationship Degree
• The number of classes that participate in a
relationship
• Main degrees:
1. Unary – a relationship between objects of the same
class
2. Binary – a relationship between objects of two
different classes
3. Ternary – a relationship between objects of three
different classes
25
26
27
Relationship Multiplicity
• Cardinality: how many instances of one class can
be related to one instance of the other class
• Multiplicity : Cardinalities that specify the range
of the number of objects in Class A that can or
must be associated with each object of Class B.
• Multiplicity must be placed at each end of the
association link.
28
Relationship Multiplicity
• A multiplicity is made up of:
1. A minimum cardinality – the minimum number of Class A objects possible
2. A maximum cardinality – the maximum number of Class A objects possible
• Relationships can be:
1. One – to – one
2. One – to – many
3. Many – to – many
4. Fixed cardinality
29
A movie is stocked as zero to many videotape(s).
* Note : 0..n is referred as zero to many
31
32
Associations
1. Association – no object is subordinate to any
other.
2. Aggregation – one class represents the whole,
and the other represents the part, but it is a loose
coupling.
• Made-up-of, consists-of, contains, is-part-of
relationship
• Eg: car is made up of parts
whole part 33
Associations
3. Composition – a type of strong aggregation with a
tight coupling. The whole and the part cannot
exist without each other.If the whole is deleted,
the parts are deleted as well.
whole part
34
Generalization
• A superclass – subclass relationship in which one
class forms a broader category in which the other
class is a sub-category
• Sometimes called ‘is-a’ relationship
• Eg: A car is a vehicle
• Inheritance – A subclass will inherit all the
attributes and operations of its superclass; an
instance of the subclass contains all the same
information (plus more) as an instance of the
superclass.
35
• Abstract class is
one that does
not allowed to
have any
objects
• Used only to
inherit from
• Label with
{abstract}
under the class
name
36
37
Multiple
inheritance is
complicated
and not
supported by
all object-
oriented
programming
languages.
38
Preparing a Class Diagram
41
References
1. George, J. F., Batra, D., Valacich, J., & Hoffer, J. A. (2004). Object-Oriented
Systems Analysis and Design. New Jersey: Pearson Prentice Hall.
2. Hoffer, J. A., George, J.F., & Valacich, J.S. (2004). Modern Systems Analysis and
Design 4th Edition.New Jersey : Pearson Prentice Hall.
3. Bennet, S., McRobb, S., & Farmer, R. (2000). Object Oriented Systems Analysis
and Design using UML. McGraw Hill.
4. Haslina Mohd, Azizah Ahmad, Azida Zainol & Azlin Nordin. (2002). Modul
Analisis dan Rekabentuk Sistem Pendekatan Berorientasikan Objek
Menggunakan UML. Prentice Hall.
5. Dennis, A., Wixom, B. H., & Tegarden, D. (2002). Systems Analysis & Design An
Object –Oriented Approach with UML. McGraw Hill.
6. Pressman, R.(2000). Software Engineering: A Practitioner's Approach. McGraw-
Hill. (Chapter 10).
7. Sommerville, I. and Sawyer, P.(1997). Requirements Engineering. Wiley.
8. Booch, Rambaugh, Jacobson. (1999). The UML User Guide. Addison Wesley.
9. Eriksson, H. E., & Penker, M. (1998). UML Toolkit. Wiley Computer Publishing.
42