SlideShare a Scribd company logo
OO & UML
Chen Bin
UML
unified model language
model / design / documentation /
understand legacy code
communication
Table 1.1. Official Diagram Types of the UML
Book
文本文本
[3]
UML diagram category
our topic
class diagram
sequence diagram
activity diagram
oo/design pattern
class diagram
describe the classes and their relationship
within the system
class diagram
class itself
class relationship
inheritance
dependency
class (itself)
pictures are captured from [apply UML & pattern]
class type
method
return/params
static/abstract
attribution visibility
class type(map java/c++)
interface
abstract class
{concrete} class
class with all pure virtual methods
class with some virtual methods
classwith no virtual methods
C++JavaUML
interface
abstract class
{concrete} class
class relationship UML
interface
implementation
composition
association
generalization
class relationship
generalization =~ subtype -> extends :
interface implementation -> implements :
UML Java C++
! ! 2 type of inheritance
interface inheritance
IC extends IA ,IB
CA implements IA
CD extends CA
CD extends CA implements CB
implementation
inheritance
Item 16, [5]
The ArrayList itself is a subclass of the AbstractList class. AbstractList provides some, but not
all, the implementation of the List behavior. In particular, the get method is abstract. As a result,
ArrayList implements get but also overrides some of the other operations on AbstractList. In
this case, it overrides add but is happy to inherit the implementation of equals.
Example
extends
extends
implements
dependency
dependency -local, parameters,static method
association - attribution
aggregation - whole-part relationship
composition - non-shared aggregation
A dependency exists between two elements if changes to the definition of
one element (the supplier) may cause changes to the other (the client).
stronger
weaker
example
65/118
Aggregation and Composition
One of the most frequent sources of confusion in the UML is aggregation and composition. It's
to explain glibly: Aggregation is the part-of relationship. It's like saying that a car has an eng
and wheels as its parts. This sounds good, but the difficult thing is considering what the differe
between aggregation and association.
In the pre-UML days, people were usually rather vague on what was aggregation and what wa
association. Whether vague or not, they were always inconsistent with everyone else. As a res
many modelers think that aggregation is important, although for different reasons. So the UML
included aggregation (Figure 5.3) but with hardly any semantics. As Jim Rumbaugh says, "Thin
as a modeling placebo" [Rumbaugh, UML Reference].
Figure 5.3. Aggregation
As well as aggregation, the UML has the more defined property of composition. In Figure
instance of Point may be part of a polygon or may be the center of a circle, but it cannot b
The general rule is that, although a class may be a component of many other classes, any
must be a component of only one owner. The class diagram may show multiple classes of
owners, but any instance has only a single object as its owner.
Figure 5.4. Composition
You'll note that I don't show the reverse multiplicities in Figure 5.4. In most cases, as here
Its only other possible value is 1, for cases in which the component class is designed so th
have only one other class as its owner.
The "no sharing" rule is the key to composition. Another assumption is that if you delete th
polygon, it should automatically ensure that any owned Points also are deleted.
Composition is a good way of showing properties that own by value, properties to value ob
(page 73), or properties that have a strong and somewhat exclusive ownership of particula
components. Aggregation is strictly meaningless; as a result, I recommend that you ignore
own diagrams. If you see it in other people's diagrams, you'll need to dig deeper to find ou
they mean by it. Different authors and teams use it for very different purposes.
Derived Properties
37/118
discuss other visibilities on page 83.
• The name of the attribute—how the class refers to the attribute—roughly corresponds to the
name of a field in a programming language.
• The type of the attribute indicates a restriction on what kind of object may be placed in the
attribute. You can think of this as the type of a field in a programming language.
• I'll explain multiplicity on page 38.
• The default value is the value for a newly created object if the attribute isn't specified
during creation.
• The {property-string} allows you to indicate additional properties for the attribute. In the
example, I used {readOnly} to indicate that clients may not modify the property. If this is
missing, you can usually assume that the attribute is modifiable. I'll describe other property
strings as we go.
Associations
The other way to notate a property is as an association. Much of the same information that you can
show on an attribute appears on an association. Figures 3.2 and 3.3 show the same properties
represented in the two different notations.
Figure 3.2. Showing properties of an order as attributes
Figure 3.3. Showing properties of an order as associations
An association is a solid line between two classes, directed from the source class to the target
class. The name of the property goes at the target end of the association, together with its
multiplicity. The target end of the association links to the class that is the type of the property.
association
[3]
aggregation or
composition?
don’t bother use aggregation, use
composition when appropriate.
[1][4]
use association for normal attribution,
use aggregation for collection of attribution
FYI[3]
65/118
Static Operations and Attributes
The UML refers to an operation or an attribute that applies to a class rather than to an instance as
static. This is equivalent to static members in C-based languages. Static features are underlined on
a class diagram (see Figure 5.2).
Figure 5.2. Static notation
Aggregation and Composition
One of the most frequent sources of confusion in the UML is aggregation and composition. It's easy
to explain glibly: Aggregation is the part-of relationship. It's like saying that a car has an engine
and wheels as its parts. This sounds good, but the difficult thing is considering what the difference is
between aggregation and association.
In the pre-UML days, people were usually rather vague on what was aggregation and what was
association. Whether vague or not, they were always inconsistent with everyone else. As a result,
many modelers think that aggregation is important, although for different reasons. So the UML
included aggregation (Figure 5.3) but with hardly any semantics. As Jim Rumbaugh says, "Think of it
as a modeling placebo" [Rumbaugh, UML Reference].
Figure 5.3. Aggregation
As well as aggregation, the UML has the more defined property of composition. In Figure 5.4, an
instance of Point may be part of a polygon or may be the center of a circle, but it cannot be both.
The general rule is that, although a class may be a component of many other classes, any instance
must be a component of only one owner. The class diagram may show multiple classes of potential
owners, but any instance has only a single object as its owner.
Figure 5.4. Composition
You'll note that I don't show the reverse multiplicities in Figure 5.4. In most cases, as here, it's 0..1.
Its only other possible value is 1, for cases in which the component class is designed so that it can
have only one other class as its owner.
The "no sharing" rule is the key to composition. Another assumption is that if you delete the
polygon, it should automatically ensure that any owned Points also are deleted.
Composition is a good way of showing properties that own by value, properties to value objects
(page 73), or properties that have a strong and somewhat exclusive ownership of particular other
components. Aggregation is strictly meaningless; as a result, I recommend that you ignore it in your
own diagrams. If you see it in other people's diagrams, you'll need to dig deeper to find out what
they mean by it. Different authors and teams use it for very different purposes.
Derived Properties
As well as aggregation, the UML has the more defined property of composition. In Figure 5.4, an
instance of Point may be part of a polygon or may be the center of a circle, but it cannot be both.
The general rule is that, although a class may be a component of many other classes, any instance
must be a component of only one owner. The class diagram may show multiple classes of potential
owners, but any instance has only a single object as its owner.
Figure 5.4. Composition
You'll note that I don't show the reverse multiplicities in Figure 5.4. In most cases, as here, it's 0..1.
Its only other possible value is 1, for cases in which the component class is designed so that it can
have only one other class as its owner.
The "no sharing" rule is the key to composition. Another assumption is that if you delete the
polygon, it should automatically ensure that any owned Points also are deleted.
Composition is a good way of showing properties that own by value, properties to value objects
(page 73), or properties that have a strong and somewhat exclusive ownership of particular other
components. Aggregation is strictly meaningless; as a result, I recommend that you ignore it in your
own diagrams. If you see it in other people's diagrams, you'll need to dig deeper to find out what
they mean by it. Different authors and teams use it for very different purposes.
Derived Properties
Derived properties can be calculated based on other values. When we think about a date range
(Figure 5.5), we can think of three properties: the start date, the end date, and the number of days
in the period. These values are linked, so we can think of the length as being derived from the other
two values.
Figure 5.5. Derived attribute in a time period
wrap up example
A class diagram describes the types of objects in the system and the various kinds of static
relationships that exist among them. Class diagrams also show the properties and operations of a
class and the constraints that apply to the way objects are connected. The UML uses the term
feature as a general term that covers properties and operations of a class.
Figure 3.1 shows a simple class model that would not surprise anyone who has worked with order
processing. The boxes in the diagram are classes, which are divided into three compartments: the
name of the class (in bold), its attributes, and its operations. Figure 3.1 also shows two kinds of
relationships between classes: associations and generalizations.
Figure 3.1. A simple class diagram
Properties
Properties represent structural features of a class. As a first approximation, you can think of
properties as corresponding to fields in a class. The reality is rather involved, as we shall see, but
that's a reasonable place to start.
advice
class diagram is the backbone of UML, so
familiar yourself with it
focus on big picture
use it with sequence diagram
sequence diagram
describe object interaction in specific user
case
sample
pic taken from [1]
sync call
async call
obj:Type
activation box
Activity Diagram
OO equivalent of flowchart in structured dev.
With addition support for concurrency
Use it describe business logic or complex algorithm
Example
[7]
OOD, Patterns & UML
UML express your OOD
Good OOD follow OOD principle
Design Pattern = proven OOD solution
OOD principle: SOLID
[6][4]
DIP
dependency inversion principle
DIP
[8]
List list = new ArrayList();
DIP - strategy pattern
programming to interface not implementation
Template Method
Hollywood principle : don’t call me , I will call you.
reference
1.apply UML & pattern , Craig Larman
2.design pattern, GOF
3.UML distilled ,Martin Fowler
4. Agile software development, Bob Martin
5. Effective Java , Joshua Bloch
6.http://en.wikipedia.org/wiki/Solid_(object-oriented_design)
7.http://www.visual-paradigm.com/VPGallery/diagrams/Activity.html
8.http://www.objectmentor.com/resources/articles/dip.pdf
9.http://exciton.cs.rice.edu/javaresources/DesignPatterns/

More Related Content

PDF
uml
Vikram Reddy
 
PPT
Object modeling
Anand Grewal
 
PPT
Uml Omg Fundamental Certification 2
Ricardo Quintero
 
PPT
Uml Omg Fundamental Certification 3
Ricardo Quintero
 
PPT
Design Pattern For C# Part 1
Shahzad
 
DOCX
Behavioural modelling
Benazir Fathima
 
PPT
UML- Unified Modeling Language
Shahzad
 
PPTX
Fundamentals of Software Engineering
Madhar Khan Pathan
 
Object modeling
Anand Grewal
 
Uml Omg Fundamental Certification 2
Ricardo Quintero
 
Uml Omg Fundamental Certification 3
Ricardo Quintero
 
Design Pattern For C# Part 1
Shahzad
 
Behavioural modelling
Benazir Fathima
 
UML- Unified Modeling Language
Shahzad
 
Fundamentals of Software Engineering
Madhar Khan Pathan
 

What's hot (20)

PPT
Uml - An Overview
Raj Thilak S
 
DOCX
Chapter 4: Enhanced Entity-Relationship and Object Modeling
Raj vardhan
 
PDF
Lecture 5 Software Engineering and Design Design Patterns
op205
 
PPT
Omg Fundamental Certification 4
Ricardo Quintero
 
PPT
Uml Omg Fundamental Certification 5
Ricardo Quintero
 
PPTX
Let us understand design pattern
Mindfire Solutions
 
PDF
Software Design Patterns. Part I :: Structural Patterns
Sergey Aganezov
 
PPT
Design Patterns
soms_1
 
PDF
Design patterns difference between interview questions
Umar Ali
 
PDF
Basic design pattern interview questions
jinaldesailive
 
ODP
Uml
parag
 
PDF
Lecture9 domain model visualizing
Shahid Riaz
 
PPT
Design Patterns (Examples in .NET)
Aniruddha Chakrabarti
 
PPTX
Abstraction1
zindadili
 
PPT
Uml in software engineering
Mubashir Jutt
 
PPT
UML Diagrams
Kartik Raghuvanshi
 
DOC
Interface Vs Abstact
Anand Kumar Rajana
 
PDF
Design Patterns Illustrated
Herman Peeren
 
PDF
Gof design pattern
naveen kumar
 
PDF
Design patterns
abhisheksagi
 
Uml - An Overview
Raj Thilak S
 
Chapter 4: Enhanced Entity-Relationship and Object Modeling
Raj vardhan
 
Lecture 5 Software Engineering and Design Design Patterns
op205
 
Omg Fundamental Certification 4
Ricardo Quintero
 
Uml Omg Fundamental Certification 5
Ricardo Quintero
 
Let us understand design pattern
Mindfire Solutions
 
Software Design Patterns. Part I :: Structural Patterns
Sergey Aganezov
 
Design Patterns
soms_1
 
Design patterns difference between interview questions
Umar Ali
 
Basic design pattern interview questions
jinaldesailive
 
Uml
parag
 
Lecture9 domain model visualizing
Shahid Riaz
 
Design Patterns (Examples in .NET)
Aniruddha Chakrabarti
 
Abstraction1
zindadili
 
Uml in software engineering
Mubashir Jutt
 
UML Diagrams
Kartik Raghuvanshi
 
Interface Vs Abstact
Anand Kumar Rajana
 
Design Patterns Illustrated
Herman Peeren
 
Gof design pattern
naveen kumar
 
Design patterns
abhisheksagi
 
Ad

Viewers also liked (20)

PPT
JavaYDL15
Terry Yoast
 
ODP
Itt1 sd uml and oo
Morten Nielsen
 
PPTX
Unified modelling language (UML)
Hirra Sultan
 
PPT
OO Development 3 - Models And UML
Randy Connolly
 
PDF
Java OO Revisited
Jussi Pohjolainen
 
PPT
Applying OO Concepts
Mohammed Irfan Shaikh
 
PPTX
Design Pattern lecture 1
Julie Iskander
 
PDF
Object oriented fundamentals_in_java
Self
 
PPTX
Introduction to OO, Java and Eclipse/WebSphere
eLink Business Innovations
 
PDF
Dependencies, dependencies, dependencies
Marcel Offermans
 
PPTX
Babok2 chapter9 daxko
Mudassir Iqbal
 
PDF
UML - Unified Modelling Language
Anoop VJ
 
PPT
OOP programming
anhdbh
 
PPT
Module 3 Object Oriented Data Models Object Oriented notations
Taher Barodawala
 
PPTX
Packaes & interfaces
yugandhar vadlamudi
 
PDF
Wrapper classes
Ravi_Kant_Sahu
 
PPT
What does OOP stand for?
Colin Riley
 
PPTX
Java 103 intro to java data structures
agorolabs
 
PPT
Object Oriented Design in Software Engineering SE12
koolkampus
 
KEY
Objects & OO Thinking for Java
Jeff Sonstein
 
JavaYDL15
Terry Yoast
 
Itt1 sd uml and oo
Morten Nielsen
 
Unified modelling language (UML)
Hirra Sultan
 
OO Development 3 - Models And UML
Randy Connolly
 
Java OO Revisited
Jussi Pohjolainen
 
Applying OO Concepts
Mohammed Irfan Shaikh
 
Design Pattern lecture 1
Julie Iskander
 
Object oriented fundamentals_in_java
Self
 
Introduction to OO, Java and Eclipse/WebSphere
eLink Business Innovations
 
Dependencies, dependencies, dependencies
Marcel Offermans
 
Babok2 chapter9 daxko
Mudassir Iqbal
 
UML - Unified Modelling Language
Anoop VJ
 
OOP programming
anhdbh
 
Module 3 Object Oriented Data Models Object Oriented notations
Taher Barodawala
 
Packaes & interfaces
yugandhar vadlamudi
 
Wrapper classes
Ravi_Kant_Sahu
 
What does OOP stand for?
Colin Riley
 
Java 103 intro to java data structures
agorolabs
 
Object Oriented Design in Software Engineering SE12
koolkampus
 
Objects & OO Thinking for Java
Jeff Sonstein
 
Ad

Similar to OO & UML (20)

PDF
Uml classdiagrams
Wahid Zaman
 
PDF
Class Diagram
Dwight Sabio
 
PPT
UML-class diagram for beginners to adance.ppt
WorkDrive2
 
PPT
cse 355 UML class diagram software engineering.ppt
Safaet Hossain
 
PPT
UML-class_diagram.ppt
PragnyaNandaSabat
 
PPT
UML-class_diagram.ppt diagrams ppt download
divijareddy0502
 
PPTX
introofUML.pptx
RojaPogul1
 
PPT
06 class diagrams
Baskarkncet
 
PPTX
Relationships and their representation in a class diagram.pptx
nesarahmad37
 
PDF
Lecture05-Structural Modeling for students.pdf
NguyenHongNhung31
 
PPTX
Ooad static diagram
TSubashiniAPIICSE
 
PPTX
Lecture 06.pptxLecture 06.pptxLecture 06.pptx
EnghamzaKhalailah
 
PPTX
210280107093_CLASS_DIAGRAM.pptx
HimeshNayi
 
PPT
Slide 5 Class Diagram
Niloy Rocker
 
PDF
Lesson #04 - Software Engineering - Practice.pdf
BeksultanMustafin
 
DOCX
Chapterunifiedmo 3 UML Class Diagram.docx
MohammedNouh7
 
PPTX
FALLSEM2024-25_SWE2018_ETH_VL2024250103302_2024-10-04_Reference-Material-I.pptx
yadavdkshitij2003
 
PDF
Class diagram and its importance in software
nazimsattar
 
PDF
Introduction to UML, a guide to learn.pdf
TARGARYEN001
 
PPT
Css uml
suman Aggarwal
 
Uml classdiagrams
Wahid Zaman
 
Class Diagram
Dwight Sabio
 
UML-class diagram for beginners to adance.ppt
WorkDrive2
 
cse 355 UML class diagram software engineering.ppt
Safaet Hossain
 
UML-class_diagram.ppt
PragnyaNandaSabat
 
UML-class_diagram.ppt diagrams ppt download
divijareddy0502
 
introofUML.pptx
RojaPogul1
 
06 class diagrams
Baskarkncet
 
Relationships and their representation in a class diagram.pptx
nesarahmad37
 
Lecture05-Structural Modeling for students.pdf
NguyenHongNhung31
 
Ooad static diagram
TSubashiniAPIICSE
 
Lecture 06.pptxLecture 06.pptxLecture 06.pptx
EnghamzaKhalailah
 
210280107093_CLASS_DIAGRAM.pptx
HimeshNayi
 
Slide 5 Class Diagram
Niloy Rocker
 
Lesson #04 - Software Engineering - Practice.pdf
BeksultanMustafin
 
Chapterunifiedmo 3 UML Class Diagram.docx
MohammedNouh7
 
FALLSEM2024-25_SWE2018_ETH_VL2024250103302_2024-10-04_Reference-Material-I.pptx
yadavdkshitij2003
 
Class diagram and its importance in software
nazimsattar
 
Introduction to UML, a guide to learn.pdf
TARGARYEN001
 

More from Bin Chen (6)

PDF
Android Things
Bin Chen
 
PDF
Overview of Brillo (Android Things)
Bin Chen
 
PDF
Overview of Brillo and Weave
Bin Chen
 
PPTX
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Bin Chen
 
PDF
Chrome & Webkit overview
Bin Chen
 
PDF
Browsers on Android (Webkit,chromium)
Bin Chen
 
Android Things
Bin Chen
 
Overview of Brillo (Android Things)
Bin Chen
 
Overview of Brillo and Weave
Bin Chen
 
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Bin Chen
 
Chrome & Webkit overview
Bin Chen
 
Browsers on Android (Webkit,chromium)
Bin Chen
 

Recently uploaded (20)

PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
PPTX
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
PDF
Software Testing Tools - names and explanation
shruti533256
 
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PDF
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
PDF
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
PDF
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PPTX
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
PDF
Zero Carbon Building Performance standard
BassemOsman1
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PDF
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
Software Testing Tools - names and explanation
shruti533256
 
July 2025: Top 10 Read Articles Advanced Information Technology
ijait
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
The Effect of Artifact Removal from EEG Signals on the Detection of Epileptic...
Partho Prosad
 
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
Zero Carbon Building Performance standard
BassemOsman1
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 

OO & UML

  • 2. UML unified model language model / design / documentation / understand legacy code communication
  • 3. Table 1.1. Official Diagram Types of the UML Book 文本文本 [3] UML diagram category
  • 4. our topic class diagram sequence diagram activity diagram oo/design pattern
  • 5. class diagram describe the classes and their relationship within the system
  • 6. class diagram class itself class relationship inheritance dependency
  • 7. class (itself) pictures are captured from [apply UML & pattern] class type method return/params static/abstract attribution visibility
  • 8. class type(map java/c++) interface abstract class {concrete} class class with all pure virtual methods class with some virtual methods classwith no virtual methods C++JavaUML interface abstract class {concrete} class
  • 10. class relationship generalization =~ subtype -> extends : interface implementation -> implements : UML Java C++
  • 11. ! ! 2 type of inheritance interface inheritance IC extends IA ,IB CA implements IA CD extends CA CD extends CA implements CB implementation inheritance Item 16, [5]
  • 12. The ArrayList itself is a subclass of the AbstractList class. AbstractList provides some, but not all, the implementation of the List behavior. In particular, the get method is abstract. As a result, ArrayList implements get but also overrides some of the other operations on AbstractList. In this case, it overrides add but is happy to inherit the implementation of equals. Example extends extends implements
  • 13. dependency dependency -local, parameters,static method association - attribution aggregation - whole-part relationship composition - non-shared aggregation A dependency exists between two elements if changes to the definition of one element (the supplier) may cause changes to the other (the client). stronger weaker
  • 14. example 65/118 Aggregation and Composition One of the most frequent sources of confusion in the UML is aggregation and composition. It's to explain glibly: Aggregation is the part-of relationship. It's like saying that a car has an eng and wheels as its parts. This sounds good, but the difficult thing is considering what the differe between aggregation and association. In the pre-UML days, people were usually rather vague on what was aggregation and what wa association. Whether vague or not, they were always inconsistent with everyone else. As a res many modelers think that aggregation is important, although for different reasons. So the UML included aggregation (Figure 5.3) but with hardly any semantics. As Jim Rumbaugh says, "Thin as a modeling placebo" [Rumbaugh, UML Reference]. Figure 5.3. Aggregation As well as aggregation, the UML has the more defined property of composition. In Figure instance of Point may be part of a polygon or may be the center of a circle, but it cannot b The general rule is that, although a class may be a component of many other classes, any must be a component of only one owner. The class diagram may show multiple classes of owners, but any instance has only a single object as its owner. Figure 5.4. Composition You'll note that I don't show the reverse multiplicities in Figure 5.4. In most cases, as here Its only other possible value is 1, for cases in which the component class is designed so th have only one other class as its owner. The "no sharing" rule is the key to composition. Another assumption is that if you delete th polygon, it should automatically ensure that any owned Points also are deleted. Composition is a good way of showing properties that own by value, properties to value ob (page 73), or properties that have a strong and somewhat exclusive ownership of particula components. Aggregation is strictly meaningless; as a result, I recommend that you ignore own diagrams. If you see it in other people's diagrams, you'll need to dig deeper to find ou they mean by it. Different authors and teams use it for very different purposes. Derived Properties 37/118 discuss other visibilities on page 83. • The name of the attribute—how the class refers to the attribute—roughly corresponds to the name of a field in a programming language. • The type of the attribute indicates a restriction on what kind of object may be placed in the attribute. You can think of this as the type of a field in a programming language. • I'll explain multiplicity on page 38. • The default value is the value for a newly created object if the attribute isn't specified during creation. • The {property-string} allows you to indicate additional properties for the attribute. In the example, I used {readOnly} to indicate that clients may not modify the property. If this is missing, you can usually assume that the attribute is modifiable. I'll describe other property strings as we go. Associations The other way to notate a property is as an association. Much of the same information that you can show on an attribute appears on an association. Figures 3.2 and 3.3 show the same properties represented in the two different notations. Figure 3.2. Showing properties of an order as attributes Figure 3.3. Showing properties of an order as associations An association is a solid line between two classes, directed from the source class to the target class. The name of the property goes at the target end of the association, together with its multiplicity. The target end of the association links to the class that is the type of the property. association [3]
  • 16. don’t bother use aggregation, use composition when appropriate. [1][4] use association for normal attribution, use aggregation for collection of attribution
  • 17. FYI[3] 65/118 Static Operations and Attributes The UML refers to an operation or an attribute that applies to a class rather than to an instance as static. This is equivalent to static members in C-based languages. Static features are underlined on a class diagram (see Figure 5.2). Figure 5.2. Static notation Aggregation and Composition One of the most frequent sources of confusion in the UML is aggregation and composition. It's easy to explain glibly: Aggregation is the part-of relationship. It's like saying that a car has an engine and wheels as its parts. This sounds good, but the difficult thing is considering what the difference is between aggregation and association. In the pre-UML days, people were usually rather vague on what was aggregation and what was association. Whether vague or not, they were always inconsistent with everyone else. As a result, many modelers think that aggregation is important, although for different reasons. So the UML included aggregation (Figure 5.3) but with hardly any semantics. As Jim Rumbaugh says, "Think of it as a modeling placebo" [Rumbaugh, UML Reference]. Figure 5.3. Aggregation As well as aggregation, the UML has the more defined property of composition. In Figure 5.4, an instance of Point may be part of a polygon or may be the center of a circle, but it cannot be both. The general rule is that, although a class may be a component of many other classes, any instance must be a component of only one owner. The class diagram may show multiple classes of potential owners, but any instance has only a single object as its owner. Figure 5.4. Composition You'll note that I don't show the reverse multiplicities in Figure 5.4. In most cases, as here, it's 0..1. Its only other possible value is 1, for cases in which the component class is designed so that it can have only one other class as its owner. The "no sharing" rule is the key to composition. Another assumption is that if you delete the polygon, it should automatically ensure that any owned Points also are deleted. Composition is a good way of showing properties that own by value, properties to value objects (page 73), or properties that have a strong and somewhat exclusive ownership of particular other components. Aggregation is strictly meaningless; as a result, I recommend that you ignore it in your own diagrams. If you see it in other people's diagrams, you'll need to dig deeper to find out what they mean by it. Different authors and teams use it for very different purposes. Derived Properties As well as aggregation, the UML has the more defined property of composition. In Figure 5.4, an instance of Point may be part of a polygon or may be the center of a circle, but it cannot be both. The general rule is that, although a class may be a component of many other classes, any instance must be a component of only one owner. The class diagram may show multiple classes of potential owners, but any instance has only a single object as its owner. Figure 5.4. Composition You'll note that I don't show the reverse multiplicities in Figure 5.4. In most cases, as here, it's 0..1. Its only other possible value is 1, for cases in which the component class is designed so that it can have only one other class as its owner. The "no sharing" rule is the key to composition. Another assumption is that if you delete the polygon, it should automatically ensure that any owned Points also are deleted. Composition is a good way of showing properties that own by value, properties to value objects (page 73), or properties that have a strong and somewhat exclusive ownership of particular other components. Aggregation is strictly meaningless; as a result, I recommend that you ignore it in your own diagrams. If you see it in other people's diagrams, you'll need to dig deeper to find out what they mean by it. Different authors and teams use it for very different purposes. Derived Properties Derived properties can be calculated based on other values. When we think about a date range (Figure 5.5), we can think of three properties: the start date, the end date, and the number of days in the period. These values are linked, so we can think of the length as being derived from the other two values. Figure 5.5. Derived attribute in a time period
  • 18. wrap up example A class diagram describes the types of objects in the system and the various kinds of static relationships that exist among them. Class diagrams also show the properties and operations of a class and the constraints that apply to the way objects are connected. The UML uses the term feature as a general term that covers properties and operations of a class. Figure 3.1 shows a simple class model that would not surprise anyone who has worked with order processing. The boxes in the diagram are classes, which are divided into three compartments: the name of the class (in bold), its attributes, and its operations. Figure 3.1 also shows two kinds of relationships between classes: associations and generalizations. Figure 3.1. A simple class diagram Properties Properties represent structural features of a class. As a first approximation, you can think of properties as corresponding to fields in a class. The reality is rather involved, as we shall see, but that's a reasonable place to start.
  • 19. advice class diagram is the backbone of UML, so familiar yourself with it focus on big picture use it with sequence diagram
  • 20. sequence diagram describe object interaction in specific user case
  • 21. sample pic taken from [1] sync call async call obj:Type activation box
  • 22. Activity Diagram OO equivalent of flowchart in structured dev. With addition support for concurrency Use it describe business logic or complex algorithm
  • 24. OOD, Patterns & UML UML express your OOD Good OOD follow OOD principle Design Pattern = proven OOD solution
  • 27. DIP [8] List list = new ArrayList();
  • 28. DIP - strategy pattern programming to interface not implementation
  • 29. Template Method Hollywood principle : don’t call me , I will call you.
  • 30. reference 1.apply UML & pattern , Craig Larman 2.design pattern, GOF 3.UML distilled ,Martin Fowler 4. Agile software development, Bob Martin 5. Effective Java , Joshua Bloch 6.http://en.wikipedia.org/wiki/Solid_(object-oriented_design) 7.http://www.visual-paradigm.com/VPGallery/diagrams/Activity.html 8.http://www.objectmentor.com/resources/articles/dip.pdf 9.http://exciton.cs.rice.edu/javaresources/DesignPatterns/