SlideShare a Scribd company logo
1 of 13
Presented by
Muhammad Arslan
Hamza Abbas
Aqeel Ahmad Khan
Saqib Masood
Decorator Design Pattern
Context Of use
Motivation
Real Life Example
consequences
UML Diagram
Implementation
Anti Patterns
Design Patterns
Design Patterns
 In software engineering, a design pattern is a general
repeatable solution to a commonly occurring problem
in software design
12 Decorator
Structural patterns
Design Patterns that ease the design by identifying a simple way
to realize relationships between entities.
The Decorator Pattern
Motivation
Want to add properties to an existing object. 3 Examples
• Add borders or scrollbars to a GUI component
• Add headers and footers to an advertisement
• Add stream functionality such as reading a line of input or compressing
a file before sending it over the wire
Intent
Attach additional responsibilities to an object dynamically. Decorators
provide a flexible alternative to subclassing to extend flexibility
Use Decorator
 To add responsibilities to individual objects dynamically
without affecting other objects
 When extending classes is impractical
• Sometimes a large number of independent
extensions are possible and would produce an explosion of
subclasses to support every combination (this inheritance
approach is on the next few slides)
 Suppose there is a Text View GUI component and you want to add
different kinds of borders and/or scrollbars to it
 You can add 3 types of borders
Plain, 3D, Fancy
 and , 1, or 2 two scrollbars
Horizontal and Vertical
 An inheritance solution requires15 classes for one view
An Application
That’s a lot of classes!
1.TextView_Plain
2.TextView_Fancy
3.TextView_3D
4.TextView_Horizontal
5.TextView_Vertical
6.TextView_Horizontal_Vertical
7.TextView_Plain_Horizontal
8.TextView_Plain_Vertical
9.TextView_Plain_Horizontal_Vertical
10.TextView_3D_Horizontal
11.TextView_3D_Vertical
12.TextView_3D_Horizontal_Vertical
13.TextView_Fancy_Horizontal
14.TextView_Fancy_Vertical
15.TextView_Fancy_Horizontal_Vertical
Consequences(1)
 More flexibility than static inheritance.
 responsibilities can be added and removed at run-time simply by attaching
and detaching them.
 Furthermore, providing different Decorator classes for a specific
Component class lets you mix and match responsibilities.
Consequences(2)
 Avoids feature-laden classes high up in the hierarchy.
 Offers a pay-as-you-go approach to adding
responsibilities.
 You can define a simple class and add functionality
incrementally with Decorator objects.
 Also easy to define new kinds of Decorators
independently.
Consequences(3)
A decorator and its component aren’t identical.
 From an object identity point of view, a decorated
component is not identical to the component itself.
 Hence you shouldn’t rely on object identity when
you use decorators.
Anti design patterns
“An Anti Pattern is a literary form that describes a commonly
occurring solution to a problem that generates decidedly negative
consequences.”
Four type of anti design patterns:
 Programming anti patterns
 Methodology anti patterns
 Design anti patterns
 Organizational anti patterns
Design Pattern(decorator design pattern) and anti pattern

More Related Content

What's hot

Uml struct2
Uml struct2Uml struct2
Uml struct2
Student
 
Object and class relationships
Object and class relationshipsObject and class relationships
Object and class relationships
Pooja mittal
 
Class and object_diagram
Class  and object_diagramClass  and object_diagram
Class and object_diagram
Sadhana28
 

What's hot (20)

Bridge pattern
Bridge patternBridge pattern
Bridge pattern
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade Pattern
 
Facade Pattern
Facade PatternFacade Pattern
Facade Pattern
 
Creational pattern
Creational patternCreational pattern
Creational pattern
 
Facade pattern
Facade patternFacade pattern
Facade pattern
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)Facade pattern presentation(.pptx)
Facade pattern presentation(.pptx)
 
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
 
Class diagram
Class diagramClass diagram
Class diagram
 
Solid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignSolid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven Design
 
Bridge
BridgeBridge
Bridge
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
The Ultimate Guide for UML Class Diagrams by Creately
The Ultimate Guide for UML Class Diagrams by CreatelyThe Ultimate Guide for UML Class Diagrams by Creately
The Ultimate Guide for UML Class Diagrams by Creately
 
Composite Design Pattern
Composite Design PatternComposite Design Pattern
Composite Design Pattern
 
Uml struct2
Uml struct2Uml struct2
Uml struct2
 
Object and class relationships
Object and class relationshipsObject and class relationships
Object and class relationships
 
Class and object_diagram
Class  and object_diagramClass  and object_diagram
Class and object_diagram
 
Design pattern - Software Engineering
Design pattern - Software EngineeringDesign pattern - Software Engineering
Design pattern - Software Engineering
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
 

Similar to Design Pattern(decorator design pattern) and anti pattern

Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISESoftware Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
sreeja_rajesh
 
Design pattern (week 2)
Design pattern (week 2)Design pattern (week 2)
Design pattern (week 2)
stanbridge
 

Similar to Design Pattern(decorator design pattern) and anti pattern (20)

Architecture and design
Architecture and designArchitecture and design
Architecture and design
 
UML-Advanced Software Engineering
UML-Advanced Software EngineeringUML-Advanced Software Engineering
UML-Advanced Software Engineering
 
OOM Unit I - III.pdf
OOM Unit I - III.pdfOOM Unit I - III.pdf
OOM Unit I - III.pdf
 
Object oriented analysis and design unit- iv
Object oriented analysis and design unit- ivObject oriented analysis and design unit- iv
Object oriented analysis and design unit- iv
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
chapter 5 Objectdesign.ppt
chapter 5 Objectdesign.pptchapter 5 Objectdesign.ppt
chapter 5 Objectdesign.ppt
 
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design PatternsNina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
 
Introduction to Rational Rose
Introduction to Rational RoseIntroduction to Rational Rose
Introduction to Rational Rose
 
Uml - An Overview
Uml - An OverviewUml - An Overview
Uml - An Overview
 
Sda 9
Sda   9Sda   9
Sda 9
 
Facadepattern
FacadepatternFacadepattern
Facadepattern
 
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISESoftware Architecture and Project Management module III : PATTERN OF ENTERPRISE
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
 
Facade pattern
Facade patternFacade pattern
Facade pattern
 
Software Designing - Software Engineering
Software Designing - Software EngineeringSoftware Designing - Software Engineering
Software Designing - Software Engineering
 
Introduction To Design Patterns
Introduction To Design PatternsIntroduction To Design Patterns
Introduction To Design Patterns
 
Design pattern (week 2)
Design pattern (week 2)Design pattern (week 2)
Design pattern (week 2)
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 

Recently uploaded

Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Recently uploaded (20)

Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
Abortion Pill Prices Boksburg [(+27832195400*)] 🏥 Women's Abortion Clinic in ...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AI
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 

Design Pattern(decorator design pattern) and anti pattern

  • 1. Presented by Muhammad Arslan Hamza Abbas Aqeel Ahmad Khan Saqib Masood
  • 2. Decorator Design Pattern Context Of use Motivation Real Life Example consequences UML Diagram Implementation Anti Patterns Design Patterns
  • 3. Design Patterns  In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design 12 Decorator
  • 4. Structural patterns Design Patterns that ease the design by identifying a simple way to realize relationships between entities.
  • 5. The Decorator Pattern Motivation Want to add properties to an existing object. 3 Examples • Add borders or scrollbars to a GUI component • Add headers and footers to an advertisement • Add stream functionality such as reading a line of input or compressing a file before sending it over the wire Intent Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing to extend flexibility
  • 6. Use Decorator  To add responsibilities to individual objects dynamically without affecting other objects  When extending classes is impractical • Sometimes a large number of independent extensions are possible and would produce an explosion of subclasses to support every combination (this inheritance approach is on the next few slides)
  • 7.  Suppose there is a Text View GUI component and you want to add different kinds of borders and/or scrollbars to it  You can add 3 types of borders Plain, 3D, Fancy  and , 1, or 2 two scrollbars Horizontal and Vertical  An inheritance solution requires15 classes for one view An Application
  • 8. That’s a lot of classes! 1.TextView_Plain 2.TextView_Fancy 3.TextView_3D 4.TextView_Horizontal 5.TextView_Vertical 6.TextView_Horizontal_Vertical 7.TextView_Plain_Horizontal 8.TextView_Plain_Vertical 9.TextView_Plain_Horizontal_Vertical 10.TextView_3D_Horizontal 11.TextView_3D_Vertical 12.TextView_3D_Horizontal_Vertical 13.TextView_Fancy_Horizontal 14.TextView_Fancy_Vertical 15.TextView_Fancy_Horizontal_Vertical
  • 9. Consequences(1)  More flexibility than static inheritance.  responsibilities can be added and removed at run-time simply by attaching and detaching them.  Furthermore, providing different Decorator classes for a specific Component class lets you mix and match responsibilities.
  • 10. Consequences(2)  Avoids feature-laden classes high up in the hierarchy.  Offers a pay-as-you-go approach to adding responsibilities.  You can define a simple class and add functionality incrementally with Decorator objects.  Also easy to define new kinds of Decorators independently.
  • 11. Consequences(3) A decorator and its component aren’t identical.  From an object identity point of view, a decorated component is not identical to the component itself.  Hence you shouldn’t rely on object identity when you use decorators.
  • 12. Anti design patterns “An Anti Pattern is a literary form that describes a commonly occurring solution to a problem that generates decidedly negative consequences.” Four type of anti design patterns:  Programming anti patterns  Methodology anti patterns  Design anti patterns  Organizational anti patterns