Upload
others
View
11
Download
0
Embed Size (px)
Citation preview
Computer Science for Engineers
Lecture 4Object Orientation – part 2
Prof. Dr. Dr.-Ing. Jivka OvtcharovaDipl. Wi.-Ing. Dan Gutu
20th of November 2009
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 2
Outline
Lecture Content
3. Object orientation
3.2. Object-oriented modelling with UML
3.3.2. Use Case models
3.2.3. Static models
3.2.4. Dynamic models
3.3. Methods of the OO Analysis and Design
1. Preface
3.1.1. Introduction
3.1.2. Objects and classes
3.1. Introduction and basic concepts
3.1.3. Attributes of object orientation
3.2.1. Intro
3.2.5. Summary
2. Basics
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 3
What is UML?
• UML stands for „Unified Modeling Language“
• The standardization of UML occurs through the OMG (Object Management Group) www.omg.org
• UML integrates almost all techniques up till now with
- Data modeling (Entity Relationship Diagrams)
- Descriptions of workflows and object behavior
- Structure implementation
• The visualization with UML supports the entire software development process
• UML is not a method, but rather a notation (description technique)
• UML is independent from the developing environment (languages, operating system, etc.)3.
2. o
bjec
t orie
nted
mod
ellin
g w
ith U
ML
3.2.
1. In
trodu
ctio
n
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 4
What is UML not?
• Not a programming language (advantageous for the modeling of complex circumstances)
• Not redundant free; often multiple representation or style possibilities: sequence and collaboration diagrams,
• Not a process description, no procedure model (even when it appears so)
• No automated tools or tool descriptions
• UML diagrams are limited in what they can express. Not everything can be represented with UML
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
1. In
trodu
ctio
n
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 5
Diagrams in UML
• UML shows the problem from multiple perspectives. Repetition of each aspect in the form of a definite diagram.
(example: the design of a house, which is comprised of a floor plan, outline, lateral view, etc.)
- Each of these diagrams has a special application area for which it was purposely designed.
• The diagrams contain different graphical elements- The meaning of the element (semantic) is exactly determined and in all diagram
forms the same.
• The UML can be very complex due to the many diagrams, but strongly represents the problem to be solved.
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
1. In
trodu
ctio
n
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 6
Diagram types in UML
• Use-Case-Model- Abstract description of the collaboration of actors with a system. Also
sometimes called a black-box system.
• Static Model- Class and instance diagrams: the most important diagram type of UML.
• Dynamic Model- Activity diagram: shows the progression of activities
- Interaction diagrams: graphical representation of a scenario(with emphasis on a timely progression)
- Condition diagram: shows the progression of conditions
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
1. In
trodu
ctio
n
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 7
Diagramtype Diagram Phase Application area
Use case diagrams
•Requirements•Definition •Creation•Delivery
Business processes, general applications
Static Models
Class diagramsInstance diagrams
•Definition •Creation
Everywhere, the class diagram is the mostImportant diagram in UML
Interactiondiagrams
Shows the information flow and the time flow of the cooperation of the objects
Dynamic Models
Collaborationdiagrams
Timeflow structure with few messages
Sequence-diagrams
Timeflow structure with few classes
State diagramsRepresentation of the dynamic behavior
Use cases
•Requirements•Definition •Creation•Delivery
•Requirements•Definition •Creation•Delivery
Diagram types and application areas
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 8
Outline
Lecture Content
3. Object orientation
3.2. Object-oriented modelling with UML
3.3.2. Use Case models
3.2.3. Static models
3.2.4. Dynamic models
3.3. Methods of the OO Analysis and Design
1. Preface
3.1.1. Introduction
3.1.2. Objects and classes
3.1. Introduction and basic concepts
3.1.3. Attributes of object orientation
3.2.1. Intro
3.2.5. Summary
2. Basics
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 9
Diagramtype Diagram Phase Application area
Use case diagrams
•Requirements•Definition •Creation•Delivery
Business processes, general applications
Static Models
Class diagramsInstance diagrams
•Definition •Creation
Everywhere, the class diagram is the mostImportant diagram in UML
Interactiondiagrams
Shows the information flow and the time flow of the cooperation of the objects
Dynamic Models
Collaborationdiagrams
Timeflow structure with few messages
Sequence-diagrams
Timeflow structure with few classes
State diagramsRepresentation of the dynamic behavior
Use cases
•Requirements•Definition •Creation•Delivery
•Requirements•Definition •Creation•Delivery
Diagram types and application areas
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 10
Use Case Model (UCM)
• Use case models describe on an abstract level the collaboration of actors (users) with a system (computer)
• Use-case models define:
- Actors: what is outside the system
- Use case: what the system should achieve
• Tasks of the use case model are:
- Limiting the system (a simple rectangle symbolizes the system borders)
- Describing the functionality (from the user’s point of view)
The use case model can be understood to be the contract between customer and developer.3.
2. o
bjec
t orie
nted
mod
ellin
g w
ith U
ML
3.2.
2. U
se C
ase
Mod
el
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 11
Elements of the UCM
• Actor: - Are all participants that must exchange
information with the system
- Doesn‘t have to be a person
- Can be another system that communicates with the compiled system
• Use Case:- Can contain more than 1 user scenario
- Describes how a business transactionshould run through the interaction of an actor with the system and
- Which steps the user must undertake in order to manage a specific operation.
Actor Use cases
System border
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
2. U
se C
ase
Mod
el
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 12
Relationships between use cases and actors (1)
• An inheritance hierarchy between actors is possible: when different actors can play similar roles, that means that they inherited these roles from the abstract actors
• The following relationship exists between the use cases:
- The “extended“ relationshipshows that a use case extends another use case
- The “uses” relationship lets us see that inside a use case, another use case appears - but which also could have appeared alone.
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
2. U
se C
ase
Mod
el
Employee
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 13
Relationships between use cases and actors (2)
• Use cases can be linked to each other, the 3 usual relations are:
• <<uses>> or also <<include>>, that reveales that a use case takes place in anotheruse case.
• <<extends>>, that reveales that in a given situation, the use case is extended byanother use case.
• The ‚extends‘-relation is represented similar to the ‚uses‘-relation by a dashed linewith arrow:
System
Open CAD-File(local)
Printengineering drawing
«uses»«extends»
Open CAD-File(through PLM)
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
2. U
se C
ase
Mod
el
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 14
Example of a Use Case Diagram
actorsUse cases
System borders
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
2. U
se C
ase
Mod
el
Employee
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 15
Outline
Lecture Content
3. Object orientation
3.2. Object-oriented modelling with UML
3.3.2. Use Case models
3.2.3. Static models
3.2.4. Dynamic models
3.3. Methods of the OO Analysis and Design
1. Preface
3.1.1. Introduction
3.1.2. Objects and classes
3.1. Introduction and basic concepts
3.1.3. Attributes of object orientation
3.2.1. Intro
3.2.5. Summary
2. Basics
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 16
Diagramtype Diagram Phase Application area
Use case diagrams
•Requirements•Definition •Creation•Delivery
Business processes, general applications
Static Models
Class diagramsInstance diagrams
•Definition •Creation
Everywhere, the class diagram is the mostImportant diagram in UML
Inte
ract
ion
diag
ram
s
Shows the information flow and the time flow of the cooperation of the objects
Dynamic Models
Collaborationdiagrams
Timeflow structure with few messages
Sequence-diagrams
Timeflow structure with few classes
State diagramsRepresentation of the dynamic behavior
Use cases
•Requirements•Definition •Creation•Delivery
•Requirements•Definition •Creation•Delivery
Diagram types and application areas
Act
ivity
diag
ram
s
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 17
Class and instance diagrams
• Class and instance diagrams are static diagrams
• Representation method for the graphic notation and semantics for the modeling of objects, classes, and their relations
• Instance diagrams are used for describing not only the test cases, but also the scenarios or examples
• UML does not describe how classes shall be determined
• No visual differentiation between objects and classes - objects are distinguished from classes only through underscoring in their notation
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
3. S
tatic
Mod
els
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 18
Representation of classes in class diagrams
• Class name: Naming of a class from the language area of application field. As the rule, a main word or an adjective (e.g., „vehicle“ or „civil vehicle“)
• Attribute: A data value (e.g., position, size, color,...). The objects of a class have the data value of this class
• Operation: A function (e.g., delay, delete, change size,..). Application to objects of a class Private attribute
Public operations
According to UML notation the class is represented in a rectangle and is comprised of:
Rectanglepositionsizecolor
move()delete()Change_size()Change_color()
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
3. S
tatic
Mod
els
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 19
Object attribute
• An object attribute of a class is the description of a data element that is available in each object of the class. The name of the object attribute is given in the description of the class
• An object carries an individual and unchangeable attribute value for each object attribute
Notation:
Example:
Object : Classname
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
3. S
tatic
Mod
els
Team meeting
titel: Stringbeginning: Dateduration: int
Classname1 D��� ����Attribute_1: data type
…Attribute_n: data type
Attribute_1 = Attributevalue_1…
Attribute_n = Attributevalue_n
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 20
ar12: Team meeting
title = „12. Department discussion “beginning = 5 -10-98 10:00
duration = 120 min
ar13: Team meeting
title = „13. Department discussion “beginning = 5 -17-98 10:00
duration = 120 min
ar14: Team meeting
title = „exhibition preparation “beginning = 5 -12-98 9:00
duration = 180 min
Team meeting
title: Stringbeginning: Dateduration: int
O C means „ O is an instance of C “
Object diagram with examples for object attributes
class Object
ObjectObject
Object attribute
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
3. S
tatic
Mod
els
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 21
Class attribute
• A class attribute is the description of a data element that is only available once for all instances of a class.
• According to UML notation the class attributes are underlined.
Notation:
Example:
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
3. S
tatic
Mod
els
Attribute1: datatypeAttribute1
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 22
ar12: Team meeting
title = „12. department discussion “beginning = 5 -10-98 10:00
duration = 120 min
ar13: Team meeting
title = „13. department discussion “beginning = 5 -17-98 10:00
duration = 120 min
ar14: Team meeting
title = „exhibition preparation “beginning = 5 -1-98 9:00
duration = 180 min
Team meetingtheme: Stringbeginning: Dateduration: intquantity : 3
Object Diagram with an Example of Class Attributes
Class attribute
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
3. S
tatic
Mod
els
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 23
Object operations
• An operation of an object is a description of a task which can be performed by every instance of the class. In the description of the class, the name of the operation is noted. The notation of a parameter list is possible but not necessary. Common operations are also called instance operations.
Notation: Example:
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
3. S
tatic
Mod
els
Team meetingtitle: Stringbeginning: Dateduration: int
room_scheduling(): voidinvite(): boolean
cancel(): void
ClassnameAttribute_1: data type
…Attribute_n: data type
Operation_1: return data type…
Operation_m: return data type
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 24
Object Diagram with an Example of Object Operations3.
2. o
bjec
t orie
nted
mod
ellin
g w
ith U
ML
3.2.
3. S
tatic
Mod
els
ar12: Team meeting
title = „12. department discussion “beginning = 5 -10-98 10:00
duration = 120 min
ar13: Team meeting
title = „13. department discussion “beginning = 5 -17-98 10:00
duration = 120 min
ar14: Team meeting
title = „exhibition preparation “beginning = 5 -1-98 9:00
duration = 180 min
Team meetingtheme: Stringbeginning: Dateduration: intquantity : 3
Class attribute
roomScheduling(): void
roomScheduling() roomScheduling()
roomScheduling()
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 25
Class Operations
• A class operation of a class is a description of a task which can be performed only with knowledge of all current instances of a class.
example:Notation:
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
3. S
tatic
Mod
els
Meeting room
reservation(): booleanapproval(): boolean
Searchforfreeroom(): void
room_number: intcapacity: int
ClassnameAttribute_1: data type
…Attribute_n: data type
Operation_1: return data type…
Operation_m: return data type
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 26
ar12: Team meeting
title = „12. department discussion “beginning = 5 -10-98 10:00
duration = 120 min
ar13: Team meeting
title = „13. department discussion “beginning = 5 -17-98 10:00
duration = 120 min
ar14: Team meeting
title = „exhibition preparation “beginning = 5 -1-98 9:00
duration = 180 min
Team meetingtheme: Stringbeginning: Dateduration: intquantity : 3
Object Diagram with an Example of Class Operations
Class attribute
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
3. S
tatic
Mod
els
countMeetings(): int
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 27
Associations
• A (binary) association between two classes K1 and K2 is a description of a fact that the instances of both classes are having a functionally important relationship to each other
• For every object of the class K1, there is an individual, changeable and final amount of objects from the class K2, with which an association is made. The same is true for objects from K2
Notation:
example:
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
3. S
tatic
Mod
els
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 28
Multiplicity of Associations
• The multiplicity is noted usually on both ends of the connection line. This tells how many objects can stand this relationship. Example: '1', '0..1', '0..*', '5..8', '5,8'
• There are differences between cardinality (# of elements) and multiplicity (area of allowed cardinality)
Notation:
example:
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
3. S
tatic
Mod
els
Class_1 Class_2Association
MultMultiplicity Mult :
n (exactly n object of the Class_2 )n..m (n till m objects of the Class_2 )
Also valid for n and m are 0 and * ( arbitrary . 0)
Prof. Dr. Dr.-Ing. Jivka Ovtcharova – CSE-Lecture – Ch. 3 - WS 09/10 - Slide 29
Multiplicity of Associations (Example)
• Class diagram:
The cardinality or multiplicity shows, howmany objects of one class are in relation withan object of another class.
It is shown by the indication of one number n (cardinality) or of a domain n..m or n..* (multiplicity), where * is an arbitrary numberfrom N0. Example: A professor can read
an arbitrary number oflectures, each lecture is readby one professor.A students attends 5 to 10lecture and in each lecturethere are 30 to * attendants.
LectureProfessorreads
attends
1 *
5…10
Student
30…*
3.2.
obj
ect o
rient
ed m
odel
ling
with
UM
L
3.2.
3. S
tatic
Mod
els