0% found this document useful (0 votes)
4 views36 pages

UML Class Diagrams for System Design

The document discusses Class Diagrams in Object-Oriented (OO) Structural Modeling, emphasizing the identification of objects and operations through nouns and verbs in System Requirements Specifications (SRS) and use cases. It explains the relationships between classes, including association, aggregation, and composition, as well as inheritance and visibility of attributes. Additionally, it presents a practical example of an Online House Rental System, detailing user roles and functionalities.
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)
4 views36 pages

UML Class Diagrams for System Design

The document discusses Class Diagrams in Object-Oriented (OO) Structural Modeling, emphasizing the identification of objects and operations through nouns and verbs in System Requirements Specifications (SRS) and use cases. It explains the relationships between classes, including association, aggregation, and composition, as well as inheritance and visibility of attributes. Additionally, it presents a practical example of an Online House Rental System, detailing user roles and functionalities.
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

CSE347

Information System Analysis and Design

Nishat Tasnim Niloy


Lecturer
Department of Computer Science and Engineering
Faculty of Science and Engineering
Topic: 7
Class Diagram

2
OO Structural Modelling
The Static View of a system may be described using UML diagrams:
UML Class Diagrams

3
Identifying objects
• Look for nouns in the SRS (System Requirements Specifications) document
• Look for NOUNS in use cases descriptions
• A NOUN may be
• Object
• Attribute of an object

4
Identifying Operations ‘methods’
• Look for verbs in the SRS (System Requirements Specifications) document

• Look for VERBS in use cases descriptions

• A VERB may be
• translated to an operation or set of operations

• A method is the code implementation of an operation.

5
Objects

6
Class and Class diagram

z Class naming: Use singular names


• because each class represents a generalized
version of a singular object.

z Class diagrams are at the core of OO Eng.

7
Class and Class diagram
• Things naturally fall into categories (computers,
automobiles, trees...).
• We refer to these categories as classes.

• An object class is an abstraction over a set of objects with


common:
• attributes (states)
• and the services (operations) (methods)
provided by each object

• Class diagrams provide the representations used by the


developers.

8
Class Card Design
ClassName Animal

-attribute1:type
+species: string
+attribute2:type
-id: int
#attribute3:type
Example -leg: int
-attribute4:type
-hand: int
-attribute5:type
-tail: boolean
…..
+carnivorous: boolean
attributen:type
+method1(par1,par2):return type
method2(par4,par2):return type +eat(carnivorous):string
-method3(par3,par4):return type +makeSound(species):string
#method4(par1,par2):return type +sleep():void
…… -breed(leg,hand,tail,species):void
+methodn(par5,par6):return type

9
Class diagrams
• Shows relationship between classes
• A class diagram may show:

Relationship
Generalization (inheritance) ”is a”
“is a kind of”

Association (dependency) does “Who does What”


“uses”
Aggregation “has”
“composed of”
Composition: Strong aggregation
10
Association, aggregation and composition
• When considering the 3 relationships, association, aggregation and
composition,

• the most general relationship is association,

• followed by aggregation

• and, finally, composition.

11
Inheritance: is a“is a kind of”
• is a type association.
• Child class ‘subclass’ can
inherit attributes and
operations from parent
class 'superclass’.

• Example: An inheritance
hierarchy in the animal
kingdom

12
Class name Library item

Catalogue number
Acquisition date
Attributes Cost
Type
Status
Number of copies
Acquire ()
Methods
Catalogue () Operations
Library class hierarchy Is a Dispose ()
Issue ()
Return ()
(Library Management Generalisation

System)
Published item Recorded item
Title Title
Is a Publisher Medium

Book Magazine Film Computer


program
Author Year Director
Edition Issue Date of release Version
Publication date Distributor Platform
ISBN
13
Library user
Name
Address
Phone
Registration #
Register ()
De-register ()
User class hierarchy
(Library Management
System) Reader Borrower
Affiliation Items on loan
Max. loans

Staff Student
Department Major subject
Department phone Home address

14
Hierarchy Diagram (UML notation)
PERSON
Name, Address
Phone, Sex
Date of Birth
ChangeAddress
EnquireDOB&Sex

IS A

CUSTOMER EMPLOYEE
Balance SIN
O/Due 30, 60, 90 Marital Status
Credit Rating This kind of arrowhead No. of Dependants
Date Paid indicates that this Date Hired
CheckCrRating relationship is one of Wage Rate
AgeBalances GiveRaise
subclassing CalcMonthPay
15
Multiple inheritance
• Rather than inheriting the attributes and services from a single parent class, a
system which supports multiple inheritance allows object classes to inherit
from several super-classes

• Can lead to semantic conflicts where attributes/services with the same name
in different super-classes have different semantics
• Makes class hierarchy reorganisation more complex
• Java does not support multiple inheritance

16
Multiple inheritance
Example: The talking book
Book Voice recording
Author Speaker
Edition Duration
Publication date Recording date
ISBN

Talking book
# Tapes

17
Ex: The character hierarchy
The Characterz class will have ASCIIcode and type as attributes (type tells the type of the character
- normal, italic, bold or underline), and normal(), bold(), italic() and underline() as operations. The
Character class children will be: Letter, PunctualSign, SpecialCharacter and Number.

18
Ex: Generalization/Specialization Hierarchy
Notation for Motor Vehicles

19
Ex: Generalization/Specialization Hierarchy

20
UML: Associations of regular classes
Association:
• Who does what relationship Who does what
Librarian works in Library

• When classes are connected


together conceptually, that
connection is called an association

21
Associations of regular classes - Who does what
• A manager supervises 1..* employees
• An employee is supervised by 1 manager

Manager Employee
1 supervises
1..*
is supervised by

22
Multiplicity of an Association
• Shows the number of objects from one class that relate with a
number of objects in an associated class.
One class can be relate to another in a:
z one-to-one
z one-to-many
z one-to-one or more
z one-to-zero or one
z one-to-a bounded interval (one-to-two through twenty)
z one-to-exactly n
z one-to-a set of choices (one-to-five or eight)
z The UML uses an asterisk (*) to represent more and to
represent many . 23
OO: Visibility of attributes or operations
• Visibility: specifies the extent to which other classes can use a given class's
attributes or operations.
• Three levels of visibility:

• + : public level (usability extends to other classes)


• # : protected level (usability is open only to classes that inherit from original
class)
• - : private level (only the original class can use the attribute or operation)

24
OO: Visibility

Ex: Public and private operations in a Hard Disk

25
Object Aggregation
• Has-a relationship

• Structural: whole/part

• Peer relationship
• Whole & parts objects can exist independently

• A special form of association

26
Object Aggregation: Peer relationship

• Whole & parts objects can exist independently


• Example: a bank (whole) has customers (as parts)
• Deleting a bank does not cascade deleting customers
• Customers can move to another bank
• Programming: whole contains an array of parts

27
Object Aggregation
• Aggregation model shows how classes (which are
collections) are composed of other classes.
• Similar to the part-of relationship in semantic
data models.

• A line joins a whole to a part (component) with


an open diamond on the line near the whole.

28
Object Aggregation
Example: An aggregation
association in the TV Set
system

z Every TV has a TV box,


screen, speaker(s),
resistors, capatitors,
transistors, ICs... and
possibly a remote control.

z Remote control can have


these parts: resistors,
capatitors, transistors, ICs,
battery, keyboard and
remote lights.

29
Object aggregation
Study pack
“has” Course title
Number
Year
“composed of” Instructor

1 1 1 1
1..* 1..* 14 1
Assignment OHP slides Lecture Videotape
notes
Credits Slides Text Tape ids.

1 1
1..3 0..3
Exercises Solutions “part of”
#Problems Text
Description Diagrams

30
Composition
• A composite is a strong type of aggregation.

• Each component in a composite can belong to just one whole .

• The symbol for a composite is the same as the symbol for an


aggregation except the diamond is filled

31
Composition - Example 1
• Human's outside:
Every person has: head, body, arms and legs.
• A composite association. In this association each
component belongs to exactly one whole .
• Whole & parts objects can NOT exist independently

32
Composition - Example 2
• A bank (whole) has many branches (parts)

• Branches can not exist independently of the whole (parts objects can NOT exist
independently)

• Deleting a bank (whole) cascades deleting branches (parts)

• But, if a branch (part) is deleted, the bank (whole) may remain

33
University Course Enrollment Design
Class Diagram (With Methods)

34
Example:

36
Exercise
Star Soft Inc. is currently working on the development of an Online House Rental System. The company
has gathered requirements and functionalities from stakeholders and is now working on the system
design. The system will have two types of users: Owners and Tenants. The database will store the
National ID, name, phone number, and email address of both owners and tenants. All users will have to
authenticate themselves before accessing the system. They will be able to update their information as
per the admin's approval.
Owners will be able to create posts that contain the specifications and pictures of their houses. Each
post will have a unique post ID, owner ID, and content. The admin will review the posts for validity
before approving them. Tenants can search for available houses and view their specifications. These
specifications will include information such as the number of rooms, bathrooms, balcony, garage
service, elevator service, address, utility bills, service charges, total rent, and owner's contact
information.
Both owners and tenants will be able to communicate with each other through messaging. They can also
report any incidents to the admin. Finally, the database will store the admin's ID, password, and email
address.
37

You might also like