0% found this document useful (0 votes)
3 views59 pages

SE Lec6 UML

The document provides an overview of software engineering concepts, focusing on software design models and the Unified Modeling Language (UML). It distinguishes between requirements and design, outlines various UML diagrams, and explains class diagrams, associations, and generalization in object-oriented modeling. Additionally, it includes examples and details on class attributes, operations, and relationships among classes.

Uploaded by

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

SE Lec6 UML

The document provides an overview of software engineering concepts, focusing on software design models and the Unified Modeling Language (UML). It distinguishes between requirements and design, outlines various UML diagrams, and explains class diagrams, associations, and generalization in object-oriented modeling. Additionally, it includes examples and details on class attributes, operations, and relationships among classes.

Uploaded by

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

Software Engineering

Software Design Models


UML
Requirements vs. Design
● Requirements:
• What the system
should do
• More abstract

● Design:
• How the system
should do it
• More detailed
Object Oriented Modeling
The Unified Modelling Language
● The Unified Modelling Language is a standard
graphical language for modelling object oriented
software
• At the end of the 1980s and the beginning of 1990s,
the first object-oriented development processes
appeared
• In 1995, another methodologist, Jacobson, joined
the team
» His work focused on use cases
• In 1997 the Object Management Group (OMG)
started the process of UML standardization
4
History of UML
Overview of UML Diagrams
Behavioral
Structural
: behavioral features of a system /
business process
: element of spec. irrespective of time
● Activity
● State machine
● Class
● Use case
● Component
● Interaction
● Deployment
● Object
● Composite structure Interaction
● Package : emphasize object interaction

• Communication(collabe
ration)
• Sequence
• Interaction overview
• Timing
13 (!!) Kinds of UML Diagrams
1) Activity 8) Object
2) Class 9) Package
3) Communication 10) Sequence
4) Component 11) State machine
5) Component structure 12) Timing
6) Deployment 13) Use case
7) Interaction
Models and Diagrams
State
State
Diagrams
Class
Diagrams
Use Case Diagrams
Use Case
Diagrams State
Use Case Use Case
Diagrams State
Diagrams
Use Case Diagrams Object
Diagrams
Diagrams
Sequence Diagrams
Diagrams
Diagrams

Scenario State
Scenario
Diagrams State
Diagrams
Collaboration
Diagrams Component
Diagrams
Diagrams Models Diagrams

Scenario Component
Scenario
Diagrams
Component
Diagrams
Deployment
Statechart
Diagrams Diagrams
Diagrams Diagrams
Activity
Diagrams
Diagrams in UML
A diagram is the graphical representation of a set of
elements, usually rendered as a connected graph of vertices
(things) and arcs (relationships).
• Class diagram shows a set of classes, interfaces, and
collaborations with their relationships.
• Object diagram shows a set of objects and their
relationships.
• Use case diagram shows a set of use cases and actors (a
special kind of class) and their relationships.
Diagrams in UML (continued)
• Interaction diagram shows an interaction,
consisting of a set of objects and the relationships,
including the messages that may be dispatched
among them.
=> A sequence diagram emphasizes the time
ordering.
=> A collaboration diagram emphasizes the
structural organization of the objects that send and
receive messages.
Diagrams in UML (continued)
• Statechart diagram shows a state machine
consisting of states, transitions, events, and activities.
• Activity diagram is a statechart diagram that shows
the flow from activity to activity within a system.
• Component diagram shows the organization and
dependencies among a set of components.
• Deployment diagram shows the configuration of
processing nodes and the components that live on them.
Class Diagrams
UML Class Diagrams
● The main symbols shown on class diagrams are:
• Classes
● represent the types of data themselves
• Associations
● represent linkages between instances of classes
• Attributes
● are simple data found in classes and their instances
• Operations
● represent the functions performed by the classes and
their instances
• Generalizations
● group classes into inheritance hierarchies
13
Notation: Classes

Window name
origin attributes
size
open()
operations
close()
move()
display()

A class is a description of a set of objects that share the same


attributes, operations, relationships and semantics.
Class

Class Name

Attribute : type

Operation (arg list) : return type


Abstract operation

Various parts are optional


Classes
● A class is simply represented as a box with the
name of the class inside
• The diagram may also show the attributes and operations
• The complete signature of an operation is:
operationName(parameterName: parameterType …):
returnType

16
Employee class (UML)
Example UML Class Diagram
Kinds of Edges

Association
Role of B
Class A Class B
Role of A

Navigability
Role name
Source Target

Dependency
Client Supplier

There are other kinds of edges


Multiplicity of associations
■one-to-one
■each student must carry exactly one ID card

■one-to-many
■one rectangle list can contain many rectangles

20
Analyzing and validating associations
• One-to-one
» For each company, there is exactly one board of
directors
» A board is the board of only one company
» A company must always have a board
» A board must always be of some company
Analyzing and validating associations
• Many-to-many
» A secretary can work for many managers
» A manager can have many secretaries
» Secretaries can work in pools
» Managers can have a group of secretaries
» Some managers might have zero secretaries.
» Is it possible for a secretary to have, perhaps
temporarily, zero managers?
Labelling associations
• Each association can be labelled, to make explicit the nature of the
association
An association model
A more complex example
• A booking is always for exactly one
passenger
» no booking with zero passengers
» a booking could never involve more than one
passenger.
• A Passenger can have any number of
Bookings
» a passenger could have no bookings at all
» a passenger could have more than one booking
Class diagram example

StudentBody Student
1 100
- firstName : String
+ main (args : String[]) - lastName : String
- homeAddress : Address
- schoolAddress : Address

+ toString() : String
Address
- streetAddress : String
- city : String
- state : String
- zipCode : long

+ toString() : String

27
Reflexive associations
• It is possible for an association to connect a class
to itself

successo *
r * Course isMutuallyExclusiveWit
*
h
*
prerequisite

2
Detailed Example: A Class Diagram for
Genealogy

• Problems
» A person must have two parents
» Marriages not properly accounted for
Genealogy example: Possible
solutions
Person Perso
name n
nam
sex e
placeOfBirt
placeOfBirt h
dateOfBirt
h
dateOfBirt hlaceOfDeat
p child
hlaceOfDeat
p child h
dateOfDeat *
h
dateOfDeat * h
h partner
* 0..2
{partner->forAll(p1,p2
| p1 <> p2
implies p1.sex <> *
p2.sex)} Woman Man
Union femalePartne
child childmalePartne
0..1 * 0..1
0..1 r r
placeOfMarriag parents
e * *
dateOfMarriag
e
dateOfDivorc Unio
e n 0..1
placeOfMarriag
parents
e
dateOfMarriag
e
dateOfDivorc
e

3
Generalisation and inheritance
● Objects are members of classes which define
attribute types and operations
● Classes may be arranged in a class hierarchy
where one class (a super-class) is a generalisation of
one or more other classes (sub-classes)
● A sub-class inherits the attributes and
operations from its super class and may add
new methods or attributes of its own
● Generalisation in the UML is implemented as
inheritance in OO programming languages
Generalization
(Inheritance)

Supertype

Subtype 1 Subtype 2
Generalization
● Specializing a superclass into two or more
subclasses
• The discriminator is a label that describes the criteria used
in the specialization

3
A generalisation hierarchy
Multiple inheritance
An example (generalization)
Person
PersonRole 0..2
name
idNumber

RegularFligh
*
EmployeeRole t
time
PassengerRole
jobFunctio flightNumber
supervisor
n *

*
* *
Booking * SpecificFligh
seatNumber t
date

3
Car

Association types 1
aggregation
1
● aggregation: "is part of" Engine
• symbolized by a clear white diamond
● composition: "is entirely made of"
Book
• stronger version of aggregation
composition
• the parts live and die with the whole
1
• symbolized by a black diamond
*
● dependency: "uses temporarily" Page
• symbolized by dotted line
• often is an implementation
detail, not an intrinsic part of dependency
that object's state
Lottery Random
Ticket
39
Composition
• A composition is a strong kind of
aggregation
» if the aggregate is destroyed, then the parts are
destroyed as well
Building * Room

• Two alternatives for addresses


Note
(Comment)

Some
item eg
class
Comment
about an item
Class diagram example
Multiplicity

Custome
r 1 Simple
Class Aggregation

Abstract Rental
Invoice
Class

Rental Item 1..*


1 0..1

Composition Simple
Generalization Association

Checkout
DVD VHS Video Screen
Movie Movie Game

42
Class attributes
● attributes (fields, instance variables)
• visibility name : type [count] = default_value
• visibility: + public
# protected
- private
~ package (default)
/ derived
• underline static attributes
• derived attribute: not stored, but can
be computed from other attribute values
• attribute example:
- balance : double = 0.00

43
An example (attributes and
associations)
Employee
Passenger RegularFlight
name *
name employeeNumbe time
number rjobFunctio flightNumbe
supervisor
n r
*

*
* *
Booking * SpecificFlight
seatNumber
date
Association classes
• Sometimes, an attribute that concerns two
associated classes cannot be placed in either
of the classes
• The following are equivalent

Studen * * CourseSectio
t n

Registratio
ngrad
e

Studen * Registratio * CourseSectio


t ngrad n
e
Instance Specification
(Object)

ObjectName: Class Name

Attribute : type

Operation (arg list) : return type


Abstract operation

Various parts are optional


Object diagram
Object Diagram
Track Instance Behavior
● Class
Diagram

● Instance
Diagram
Object aggregation
Noun Identification: A Library
Example

The library contains books and journals. It may have


several copies of a given book. Some of the books are
reserved for short-term loans only. All others may be
borrowed by any library member for three weeks. Members
of the library can normally borrow up to six items at a time,
but members of staff may borrow up to 12 items at one time.
Only members of staff may borrow journals.

The system must keep track of when books and journals are
Noun Identification: A Library
Example

The library contains books and journals. It may have


several copies of a given book. Some of the books are
reserved for short-term loans only. All others may be
borrowed by any library member for three weeks. Members
of the library can normally borrow up to six items at a time,
but members of staff may borrow up to 12 items at one time.
Only members of staff may borrow journals.

The system must keep track of when books and journals are
Candidate Classes
Library the name of the system
Book
Journal
Copy
ShortTermLoan event
LibraryMember
Week measure
MemberOfLibrary repeat
Item book or journal
Time abstract term
MemberOfStaff
System general term
Rule general term
Relations between Classes

Book is an Item
Journal is an Item
Copy is a copy of a Book
LibraryMember
Item
MemberOfStaff is a LibraryMember

Is Item needed?
Operations

LibraryMember borrows Copy


LibraryMember returns Copy
MemberOfStaff borrows Journal
MemberOfStaff returns Journal

Item not needed yet.


Class Diagram
MemberOfStaff LibraryMember

1 1

on loan on loan

0..12 0..*
Journal Copy is a copy Book
of
1..* 1

You might also like