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

Lecture 9 - UML Structural Diagrams

- Order and Customer are the main classes, with a one-to-many relationship as a customer can have multiple orders - Order is an abstract class with two concrete subclasses: PurchaseOrder and RentalOrder - The class diagram would show the Customer and Order classes connected by a line indicating a one-to-many association, with the Order class generalized into the PurchaseOrder and RentalOrder subclasses.

Uploaded by

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

Lecture 9 - UML Structural Diagrams

- Order and Customer are the main classes, with a one-to-many relationship as a customer can have multiple orders - Order is an abstract class with two concrete subclasses: PurchaseOrder and RentalOrder - The class diagram would show the Customer and Order classes connected by a line indicating a one-to-many association, with the Order class generalized into the PurchaseOrder and RentalOrder subclasses.

Uploaded by

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

1

SE-2101 Software
Engineering

Lecture # 09

2
Today’s Agenda
Introduction to UML
 UML Structure Diagrams
 UML Class Diagram

 UML Object Diagram

3
Unified Modeling Language
Everything is fine BUT
 How do we use that information to translate our
requirements into a system model?
 How do we physically represent that model?

THE UNIFIED MODELLING LANGUAGE


AKA
UML
What is UML?
 The Unified Modeling Language (UML) is a general-
purpose modeling language in the field of Software
Engineering, which is designed to provide a standard
way to visualize the design of a system
UML Diagram – What is UML?
The Unified Modeling Language (UML) is a standard language for

Specifying Visualizing Constructing Documenting

Business Modeling Communications

7
History of UML
UML: First Pass
 You can model 80% of most problems by using about 20
% UML.
UML Diagrams
11
Note, items in blue are not part of official taxonomy of UML 2.5 diagrams
12
Note, items in blue are not part of official taxonomy of UML 2.5 diagrams
Structure Diagrams
• Structure diagram shows the static structure of
the system and how those parts are related to each
other.
• Structure diagrams are not utilizing time-related
concepts, and do not show the details of dynamic
behavior.
UML Class Diagram
UML Class Diagram

• Class diagram is basically a graphical representation


of the static view of the system and represents
different aspects of the application.
• A collection of class diagrams represent the whole
system
Classes

ClassName A class is rendered as a rectangle,


usually including its name, attributes,
and operations in separate,
attributes
designated compartments.

operations

Software Design (UML)


Class Names

• The name of the class is the only


ClassName
required tag in the graphical
representation of a class.
attributes • It always appears in the top-most
compartment.
operations

Software Design (UML)


Class Attributes

ClassName Attributes represent the properties


associated with a class. They describe
the characteristics or state of objects
attributes
belonging to the class. Attributes are
typically depicted as a name followed
operations by a data type.
Example: Consider a class representing
a "Car." It might have attributes such as:
•model: String (to store the car's model)
•color: String (to store the color of the
car)

Software Design (UML)


Class Attributes

Person

name : String
• In the class diagram, attributes
address : Address appear in the second compartment
birthdate : Date just below the name-compartment.
cnic : Id

Software Design (UML)


Visibility
Visibility specification in class diagram:

Public +
Private -
Protected #
Derived /
Visibility
• Public visibility allows unrestricted access to the
class's attributes and operations from any other
class or object
• Private visibility restricts access to only the
methods and attributes within the same class.
Other classes or objects cannot access these
members directly.
• Protected visibility allows access to the members
from within the class itself and from subclasses
(inheritance), but not from unrelated classes.
Class Operations
Operations define the behavior or
methods that an object of the class can
ClassName perform. They represent the functions
that can be called on objects of the class.
attributes Operations are typically depicted as a
name, a list of parameters (if any), and a
return type (if the operation returns a
operations
value).
For the same "Car" class, you might
have operations such as:
•startEngine(): void (to start the car's
engine)
•stopEngine(): void (to stop the car's
engine)
Software Design (UML)
Class Operations

Person

name : String
address : Address
birthdate : Date
cnic : Id

Eat () Operations describe the class behavior


Sleep () and appear in the third compartment.
Work ()
Play ()
They are services the class provides.

Software Design (UML)


Classes

ClassName

attributes

operations

Software Design (UML)


Depicting Classes
When drawing a class, you needn’t show attributes and operation in
every diagram.

Person Person
Person

name : String
birthdate : Date
Person ssn : Id

name Person eat()


address sleep()
birthdate work()
Eat () play()
Play ()

Software Design (UML)


Relationships
 Lines or arrows between classes indicate
relationships.
Types of Relationships
Relationships
 Association
 A relationship between instances of two classes,
where one class must know about the other to
do its work, e.g., client communicates to server
 indicated by a straight line or arrow
Unary Association
Person knows about Address, but Address knows nothing about Person
Binary Association

Both entities know about each other


Association Relationship
Association Relationships (Cont’d)
• We can indicate the multiplicity of an association by
adding multiplicity adornments to the line denoting the
association.

• The example indicates that a Student has one or more


Instructors:
Student Instructor
1..*

Software Design (UML)


Association Relationships (Cont’d)

The example indicates that every Instructor has one or


more Students:

Student Instructor
1..*

Software Design (UML)


Association Relationships (Cont’d)
We can also indicatea the behavior of an object in an
association (i.e., the role of an object) using rolenames.

teaches learns from


Student Instructor
1..* 1..*

Software Design (UML)


Association Relationships (Cont’d)

We can also name the association.

membership
Student Team
1..* 1..*

Software Design (UML)


Association Relationships (Cont’d)

We can specify dual associations.

member of

1..* 1..*
Student Team

1 president of 1..*

Software Design (UML)


Relationships
Aggregation: “is part of”
 An association where one class belongs to a
collection, e.g., instructor part of Faculty
 Indicated by an empty diamond on the side of the
collection
Aggregation
Aggregation is an association with a “collection-member” relationship
Relationships
 Composition: “is entirely made of”
 Strong form of Aggregation
 Lifetime control; components cannot exist without
the aggregate
 Indicated by a solid diamond on the side of the
collection
Composition
 Composition is Aggregation with Lifetime Control (owner
controls construction, destruction)
 Part object may belong to only one whole object
Relationships
 Inheritance
 An inheritance link indicating one class a
superclass relationship, e.g. bird is part of
mammal
 Indicated by a triangle pointing to superclass
 When to use inheritance?
Inheritance
Standard concept of inheritance

Base Class

Derived Class

class B() extends A



Class Attributes (Cont’d)
Attributes are usually listed in the form:
Person
attributeName : Type

name : String A derived attribute is one that can be


address : Address
birthdate : Date
computed from other attributes, but
/ age : Date doesn’t actually exist. For example,
ssn : Id a Person’s age can be computed from
his birth date. A derived attribute is
designated by a preceding ‘/’ as in:

/ age : Date

Software Design (UML)


Case Study

44
Case Study
 First of all, Order and Customer are identified as the two
elements of the system.
 They have a one-to-many relationship because a
customer can have multiple orders.
 Order class is an abstract class and it has two concrete
classes (inheritance relationship) SpecialOrder and
NormalOrder.
 The two inherited classes have all the properties as the
Order class. In addition, they have additional functions
like dispatch () and receive ()

45
Case Study - Solution

46
The End.

47

You might also like