SlideShare a Scribd company logo
1 of 30
Download to read offline
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

What's hot

Chapter 4: Enhanced Entity-Relationship and Object Modeling
Chapter 4:  Enhanced Entity-Relationship and Object ModelingChapter 4:  Enhanced Entity-Relationship and Object Modeling
Chapter 4: Enhanced Entity-Relationship and Object ModelingRaj vardhan
 
Lecture 5 Software Engineering and Design Design Patterns
Lecture 5 Software Engineering and Design Design PatternsLecture 5 Software Engineering and Design Design Patterns
Lecture 5 Software Engineering and Design Design Patternsop205
 
Omg Fundamental Certification 4
Omg Fundamental Certification 4Omg Fundamental Certification 4
Omg Fundamental Certification 4Ricardo Quintero
 
Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Ricardo Quintero
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design patternMindfire Solutions
 
Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSergey Aganezov
 
Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 
Design patterns difference between interview questions
Design patterns   difference between interview questionsDesign patterns   difference between interview questions
Design patterns difference between interview questionsUmar Ali
 
Basic design pattern interview questions
Basic design pattern interview questionsBasic design pattern interview questions
Basic design pattern interview questionsjinaldesailive
 
Lecture9 domain model visualizing
Lecture9 domain model visualizingLecture9 domain model visualizing
Lecture9 domain model visualizingShahid Riaz
 
Abstraction1
Abstraction1Abstraction1
Abstraction1zindadili
 
Uml in software engineering
Uml in software engineeringUml in software engineering
Uml in software engineeringMubashir Jutt
 
Design Patterns Illustrated
Design Patterns IllustratedDesign Patterns Illustrated
Design Patterns IllustratedHerman Peeren
 
Gof design pattern
Gof design patternGof design pattern
Gof design patternnaveen kumar
 

What's hot (20)

Uml - An Overview
Uml - An OverviewUml - An Overview
Uml - An Overview
 
Chapter 4: Enhanced Entity-Relationship and Object Modeling
Chapter 4:  Enhanced Entity-Relationship and Object ModelingChapter 4:  Enhanced Entity-Relationship and Object Modeling
Chapter 4: Enhanced Entity-Relationship and Object Modeling
 
Lecture 5 Software Engineering and Design Design Patterns
Lecture 5 Software Engineering and Design Design PatternsLecture 5 Software Engineering and Design Design Patterns
Lecture 5 Software Engineering and Design Design Patterns
 
Omg Fundamental Certification 4
Omg Fundamental Certification 4Omg Fundamental Certification 4
Omg Fundamental Certification 4
 
Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
 
Software Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural PatternsSoftware Design Patterns. Part I :: Structural Patterns
Software Design Patterns. Part I :: Structural Patterns
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design patterns difference between interview questions
Design patterns   difference between interview questionsDesign patterns   difference between interview questions
Design patterns difference between interview questions
 
Basic design pattern interview questions
Basic design pattern interview questionsBasic design pattern interview questions
Basic design pattern interview questions
 
Uml
UmlUml
Uml
 
Lecture9 domain model visualizing
Lecture9 domain model visualizingLecture9 domain model visualizing
Lecture9 domain model visualizing
 
Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)Design Patterns (Examples in .NET)
Design Patterns (Examples in .NET)
 
Abstraction1
Abstraction1Abstraction1
Abstraction1
 
Uml in software engineering
Uml in software engineeringUml in software engineering
Uml in software engineering
 
UML Diagrams
UML DiagramsUML Diagrams
UML Diagrams
 
Interface Vs Abstact
Interface Vs AbstactInterface Vs Abstact
Interface Vs Abstact
 
Design Patterns Illustrated
Design Patterns IllustratedDesign Patterns Illustrated
Design Patterns Illustrated
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
Design patterns
Design patternsDesign patterns
Design patterns
 

Viewers also liked

Unified modelling language (UML)
Unified modelling language (UML)Unified modelling language (UML)
Unified modelling language (UML)Hirra Sultan
 
OO Development 3 - Models And UML
OO Development 3 - Models And UMLOO Development 3 - Models And UML
OO Development 3 - Models And UMLRandy Connolly
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1Julie Iskander
 
Object oriented fundamentals_in_java
Object oriented fundamentals_in_javaObject oriented fundamentals_in_java
Object oriented fundamentals_in_javaSelf
 
Introduction to OO, Java and Eclipse/WebSphere
Introduction to OO, Java and Eclipse/WebSphereIntroduction to OO, Java and Eclipse/WebSphere
Introduction to OO, Java and Eclipse/WebSphereeLink Business Innovations
 
Dependencies, dependencies, dependencies
Dependencies, dependencies, dependenciesDependencies, dependencies, dependencies
Dependencies, dependencies, dependenciesMarcel Offermans
 
Babok2 chapter9 daxko
Babok2 chapter9 daxko Babok2 chapter9 daxko
Babok2 chapter9 daxko Mudassir Iqbal
 
UML - Unified Modelling Language
UML - Unified Modelling LanguageUML - Unified Modelling Language
UML - Unified Modelling LanguageAnoop VJ
 
OOP programming
OOP programmingOOP programming
OOP programminganhdbh
 
Module 3 Object Oriented Data Models Object Oriented notations
Module 3  Object Oriented Data Models Object Oriented notationsModule 3  Object Oriented Data Models Object Oriented notations
Module 3 Object Oriented Data Models Object Oriented notationsTaher Barodawala
 
What does OOP stand for?
What does OOP stand for?What does OOP stand for?
What does OOP stand for?Colin Riley
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structuresagorolabs
 
Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12koolkampus
 
Objects & OO Thinking for Java
Objects & OO Thinking for JavaObjects & OO Thinking for Java
Objects & OO Thinking for JavaJeff Sonstein
 

Viewers also liked (20)

JavaYDL15
JavaYDL15JavaYDL15
JavaYDL15
 
Itt1 sd uml and oo
Itt1 sd uml and ooItt1 sd uml and oo
Itt1 sd uml and oo
 
Unified modelling language (UML)
Unified modelling language (UML)Unified modelling language (UML)
Unified modelling language (UML)
 
OO Development 3 - Models And UML
OO Development 3 - Models And UMLOO Development 3 - Models And UML
OO Development 3 - Models And UML
 
Java OO Revisited
Java OO RevisitedJava OO Revisited
Java OO Revisited
 
Applying OO Concepts
Applying OO ConceptsApplying OO Concepts
Applying OO Concepts
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
 
Object oriented fundamentals_in_java
Object oriented fundamentals_in_javaObject oriented fundamentals_in_java
Object oriented fundamentals_in_java
 
Introduction to OO, Java and Eclipse/WebSphere
Introduction to OO, Java and Eclipse/WebSphereIntroduction to OO, Java and Eclipse/WebSphere
Introduction to OO, Java and Eclipse/WebSphere
 
Dependencies, dependencies, dependencies
Dependencies, dependencies, dependenciesDependencies, dependencies, dependencies
Dependencies, dependencies, dependencies
 
Babok2 chapter9 daxko
Babok2 chapter9 daxko Babok2 chapter9 daxko
Babok2 chapter9 daxko
 
UML - Unified Modelling Language
UML - Unified Modelling LanguageUML - Unified Modelling Language
UML - Unified Modelling Language
 
OOP programming
OOP programmingOOP programming
OOP programming
 
Module 3 Object Oriented Data Models Object Oriented notations
Module 3  Object Oriented Data Models Object Oriented notationsModule 3  Object Oriented Data Models Object Oriented notations
Module 3 Object Oriented Data Models Object Oriented notations
 
Packaes & interfaces
Packaes & interfacesPackaes & interfaces
Packaes & interfaces
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
What does OOP stand for?
What does OOP stand for?What does OOP stand for?
What does OOP stand for?
 
Java 103 intro to java data structures
Java 103   intro to java data structuresJava 103   intro to java data structures
Java 103 intro to java data structures
 
Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12
 
Objects & OO Thinking for Java
Objects & OO Thinking for JavaObjects & OO Thinking for Java
Objects & OO Thinking for Java
 

Similar to OO & UML - Class Diagrams (20)

Class Diagram
Class DiagramClass Diagram
Class Diagram
 
Uml classdiagrams
Uml classdiagramsUml classdiagrams
Uml classdiagrams
 
Class diagram
Class diagramClass diagram
Class diagram
 
Ooad static diagram
Ooad static diagramOoad static diagram
Ooad static diagram
 
Ooad ch 4
Ooad ch 4Ooad ch 4
Ooad ch 4
 
UML Design.pptx
UML Design.pptxUML Design.pptx
UML Design.pptx
 
Intro Uml
Intro UmlIntro Uml
Intro Uml
 
2 class use case
2 class use case2 class use case
2 class use case
 
UML
UMLUML
UML
 
Css uml
Css umlCss uml
Css uml
 
08 class and sequence diagrams
08   class and sequence diagrams08   class and sequence diagrams
08 class and sequence diagrams
 
Lecture 4-oop class diagram
Lecture 4-oop class diagramLecture 4-oop class diagram
Lecture 4-oop class diagram
 
UML-Advanced Software Engineering
UML-Advanced Software EngineeringUML-Advanced Software Engineering
UML-Advanced Software Engineering
 
DISE - OOAD Using UML
DISE - OOAD Using UMLDISE - OOAD Using UML
DISE - OOAD Using UML
 
8815346
88153468815346
8815346
 
Software Testing and UML Lab
Software Testing and UML LabSoftware Testing and UML Lab
Software Testing and UML Lab
 
Domain model Refinement
Domain model RefinementDomain model Refinement
Domain model Refinement
 
Unit 2
Unit 2Unit 2
Unit 2
 
Interfaces & Packages V2
Interfaces & Packages V2Interfaces & Packages V2
Interfaces & Packages V2
 
Types of UML diagrams
Types of UML diagramsTypes of UML diagrams
Types of UML diagrams
 

More from Bin Chen

Android Things
Android ThingsAndroid Things
Android ThingsBin Chen
 
Overview of Brillo (Android Things)
Overview of Brillo (Android Things)Overview of Brillo (Android Things)
Overview of Brillo (Android Things)Bin Chen
 
Overview of Brillo and Weave
Overview of Brillo and WeaveOverview of Brillo and Weave
Overview of Brillo and WeaveBin Chen
 
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveAndroid graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveBin Chen
 
Chrome & Webkit overview
Chrome & Webkit overviewChrome & Webkit overview
Chrome & Webkit overviewBin Chen
 
Browsers on Android (Webkit,chromium)
Browsers on Android (Webkit,chromium)Browsers on Android (Webkit,chromium)
Browsers on Android (Webkit,chromium)Bin Chen
 

More from Bin Chen (6)

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

Recently uploaded

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 

Recently uploaded (20)

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 

OO & UML - Class Diagrams

  • 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/