Upload
duongkhanh
View
230
Download
0
Embed Size (px)
Citation preview
ClassificationNotation
Examples
UML - Object Diagrams
Linda Marshall and Vreda Pieterse
Department of Computer ScienceUniversity of Pretoria
2014
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Overview
1 Classification
2 Notation
3 Examples
Template Method
Factory Method
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Object diagrams:
are derived from Class diagrams and
are therefore dependent on class
diagramsrepresent an instance of a class diagram
also a static viewa snapshot of the system at a specificmoment
are used for forward and reverse
engineering
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Object diagrams (cont):
are concrete in nature, represent the
real-world vs class diagrams that are
abstract and represent the blue-print
have unlimited instances vs fixed classes
of class diagrams
use the same basic relationships to class
diagrams
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Template MethodFactory Method
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Template MethodFactory Method
1 A r r a y L i s t ∗ a r r = new D e s c e n d i n g A r r a y L i s t ( 1 0 ) ;23 a r r−>i n s e r t E l e m e n t ( 1 0 ) ;4 a r r−>i n s e r t E l e m e n t ( 2 0 ) ;5 a r r−>i n s e r t E l e m e n t ( 1 5 ) ;6 a r r−>i n s e r t E l e m e n t ( 2 5 ) ;7 a r r−>i n s e r t E l e m e n t ( 5 ) ;89 a r r−>p r i n t ( ) ;
10 a r r−>s o r t ( ) ;11 a r r−>p r i n t ( ) ;
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Template MethodFactory Method
Line 1 Line 5 Line 10
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Template MethodFactory Method
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Template MethodFactory Method
Creator* factory[2];
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Template MethodFactory Method
factory[0] = new BaroneCreator();
factory[1] = new TexCreator();
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Template MethodFactory Method
Chocolate* storage[5];
Linda Marshall and Vreda Pieterse UML - Object Diagrams
ClassificationNotation
Examples
Template MethodFactory Method
for i < 2:
for (int i = 0; i < 5; i++)
storage[i] =
factory[i%2]->produce();
Linda Marshall and Vreda Pieterse UML - Object Diagrams