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
PPT
Object modeling
PPT
Uml Omg Fundamental Certification 2
PPT
Uml Omg Fundamental Certification 3
PPT
Design Pattern For C# Part 1
DOCX
Behavioural modelling
PPT
UML- Unified Modeling Language
PPTX
Fundamentals of Software Engineering
Object modeling
Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 3
Design Pattern For C# Part 1
Behavioural modelling
UML- Unified Modeling Language
Fundamentals of Software Engineering

What's hot (20)

PPT
Uml - An Overview
DOCX
Chapter 4: Enhanced Entity-Relationship and Object Modeling
PDF
Lecture 5 Software Engineering and Design Design Patterns
PPT
Omg Fundamental Certification 4
PPT
Uml Omg Fundamental Certification 5
PPTX
Let us understand design pattern
PDF
Software Design Patterns. Part I :: Structural Patterns
PPT
Design Patterns
PDF
Design patterns difference between interview questions
PDF
Basic design pattern interview questions
ODP
Uml
PDF
Lecture9 domain model visualizing
PPT
Design Patterns (Examples in .NET)
PPTX
Abstraction1
PPT
Uml in software engineering
PPT
UML Diagrams
DOC
Interface Vs Abstact
PDF
Design Patterns Illustrated
PDF
Gof design pattern
PDF
Design patterns
Uml - An Overview
Chapter 4: Enhanced Entity-Relationship and Object Modeling
Lecture 5 Software Engineering and Design Design Patterns
Omg Fundamental Certification 4
Uml Omg Fundamental Certification 5
Let us understand design pattern
Software Design Patterns. Part I :: Structural Patterns
Design Patterns
Design patterns difference between interview questions
Basic design pattern interview questions
Uml
Lecture9 domain model visualizing
Design Patterns (Examples in .NET)
Abstraction1
Uml in software engineering
UML Diagrams
Interface Vs Abstact
Design Patterns Illustrated
Gof design pattern
Design patterns
Ad

Viewers also liked (20)

PPT
JavaYDL15
ODP
Itt1 sd uml and oo
PPTX
Unified modelling language (UML)
PPT
OO Development 3 - Models And UML
PDF
Java OO Revisited
PPT
Applying OO Concepts
PPTX
Design Pattern lecture 1
PDF
Object oriented fundamentals_in_java
PPTX
Introduction to OO, Java and Eclipse/WebSphere
PDF
Dependencies, dependencies, dependencies
PPTX
Babok2 chapter9 daxko
PDF
UML - Unified Modelling Language
PPT
OOP programming
PPT
Module 3 Object Oriented Data Models Object Oriented notations
PPTX
Packaes & interfaces
PDF
Wrapper classes
PPT
What does OOP stand for?
PPTX
Java 103 intro to java data structures
PPT
Object Oriented Design in Software Engineering SE12
KEY
Objects & OO Thinking for Java
JavaYDL15
Itt1 sd uml and oo
Unified modelling language (UML)
OO Development 3 - Models And UML
Java OO Revisited
Applying OO Concepts
Design Pattern lecture 1
Object oriented fundamentals_in_java
Introduction to OO, Java and Eclipse/WebSphere
Dependencies, dependencies, dependencies
Babok2 chapter9 daxko
UML - Unified Modelling Language
OOP programming
Module 3 Object Oriented Data Models Object Oriented notations
Packaes & interfaces
Wrapper classes
What does OOP stand for?
Java 103 intro to java data structures
Object Oriented Design in Software Engineering SE12
Objects & OO Thinking for Java
Ad

Similar to OO & UML (20)

PDF
Uml classdiagrams
PDF
Class Diagram
PPT
UML-class diagram for beginners to adance.ppt
PPT
cse 355 UML class diagram software engineering.ppt
PPT
UML-class_diagram.ppt
PPT
UML-class_diagram.ppt diagrams ppt download
PPTX
introofUML.pptx
PPT
06 class diagrams
PPTX
Relationships and their representation in a class diagram.pptx
PDF
Lecture05-Structural Modeling for students.pdf
PPTX
Ooad static diagram
PPTX
Lecture 06.pptxLecture 06.pptxLecture 06.pptx
PPTX
210280107093_CLASS_DIAGRAM.pptx
PPT
Slide 5 Class Diagram
PDF
Lesson #04 - Software Engineering - Practice.pdf
DOCX
Chapterunifiedmo 3 UML Class Diagram.docx
PPTX
FALLSEM2024-25_SWE2018_ETH_VL2024250103302_2024-10-04_Reference-Material-I.pptx
PDF
Class diagram and its importance in software
PDF
Introduction to UML, a guide to learn.pdf
PPT
Uml classdiagrams
Class Diagram
UML-class diagram for beginners to adance.ppt
cse 355 UML class diagram software engineering.ppt
UML-class_diagram.ppt
UML-class_diagram.ppt diagrams ppt download
introofUML.pptx
06 class diagrams
Relationships and their representation in a class diagram.pptx
Lecture05-Structural Modeling for students.pdf
Ooad static diagram
Lecture 06.pptxLecture 06.pptxLecture 06.pptx
210280107093_CLASS_DIAGRAM.pptx
Slide 5 Class Diagram
Lesson #04 - Software Engineering - Practice.pdf
Chapterunifiedmo 3 UML Class Diagram.docx
FALLSEM2024-25_SWE2018_ETH_VL2024250103302_2024-10-04_Reference-Material-I.pptx
Class diagram and its importance in software
Introduction to UML, a guide to learn.pdf

More from Bin Chen (6)

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

Recently uploaded (20)

PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Digital Logic Computer Design lecture notes
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
PPT on Performance Review to get promotions
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
additive manufacturing of ss316l using mig welding
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Welding lecture in detail for understanding
PDF
composite construction of structures.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Embodied AI: Ushering in the Next Era of Intelligent Systems
Digital Logic Computer Design lecture notes
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPT on Performance Review to get promotions
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
OOP with Java - Java Introduction (Basics)
additive manufacturing of ss316l using mig welding
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Internet of Things (IOT) - A guide to understanding
Model Code of Practice - Construction Work - 21102022 .pdf
Welding lecture in detail for understanding
composite construction of structures.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...

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/