SlideShare a Scribd company logo
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 (20)

PPT
Bridge pattern
Shakil Ahmed
 
PPTX
Design Pattern - Introduction
Mudasir Qazi
 
PPTX
Design pattern - Facade Pattern
Mudasir Qazi
 
PPTX
Facade Pattern
melbournepatterns
 
PPTX
Creational pattern
Himanshu
 
PPT
Facade pattern
Shakil Ahmed
 
PPTX
Design Pattern
Himanshu
 
PPTX
Facade pattern presentation(.pptx)
VishalChavan83
 
PDF
Software Design Patterns. Part I :: Structural Patterns
Sergey Aganezov
 
PPTX
Class diagram
SESP123
 
PDF
Solid principles, Design Patterns, and Domain Driven Design
Irwansyah Irwansyah
 
ODP
Bridge
Iryney Baran
 
PDF
Gof design pattern
naveen kumar
 
PPTX
The Ultimate Guide for UML Class Diagrams by Creately
Creately
 
PPT
Composite Design Pattern
Ferdous Mahmud Shaon
 
PPT
Uml struct2
Student
 
PPT
Object and class relationships
Pooja mittal
 
PPTX
Class and object_diagram
Sadhana28
 
PPTX
Design pattern - Software Engineering
Nadimozzaman Pappo
 
PPTX
PATTERNS04 - Structural Design Patterns
Michael Heron
 
Bridge pattern
Shakil Ahmed
 
Design Pattern - Introduction
Mudasir Qazi
 
Design pattern - Facade Pattern
Mudasir Qazi
 
Facade Pattern
melbournepatterns
 
Creational pattern
Himanshu
 
Facade pattern
Shakil Ahmed
 
Design Pattern
Himanshu
 
Facade pattern presentation(.pptx)
VishalChavan83
 
Software Design Patterns. Part I :: Structural Patterns
Sergey Aganezov
 
Class diagram
SESP123
 
Solid principles, Design Patterns, and Domain Driven Design
Irwansyah Irwansyah
 
Bridge
Iryney Baran
 
Gof design pattern
naveen kumar
 
The Ultimate Guide for UML Class Diagrams by Creately
Creately
 
Composite Design Pattern
Ferdous Mahmud Shaon
 
Uml struct2
Student
 
Object and class relationships
Pooja mittal
 
Class and object_diagram
Sadhana28
 
Design pattern - Software Engineering
Nadimozzaman Pappo
 
PATTERNS04 - Structural Design Patterns
Michael Heron
 

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

PPT
Design patterns structuralpatterns(thedecoratorpattern)
APU
 
PPTX
Decorator Design Pattern
Kanushka Gayan
 
PPTX
Decorator design pattern
Neelima Sanagavarapu
 
PPTX
Decorator Pattern 2.pptxdsadsadsadsadasdasdsa
baocongle204
 
PPT
10-DesignPatterns.ppt
TAGADPALLEWARPARTHVA
 
PPT
Design patterns represent the best practices used by experienced object-orien...
nevanak569
 
PDF
Structure-Decorator deign pattern model fact
mdimberu
 
PDF
DECORATOR PATTERN IN WEB APPLICATION Design
ijait
 
PDF
DECORATOR PATTERN IN WEB APPLICATION
ijait
 
PPT
Stoop 439-decorator
The World of Smalltalk
 
PPTX
Omg! Patterns <decorator> by Max Titov
Max Titov
 
ODP
Design Patterns Part1
Tom Chen
 
PPTX
Decorator pattern
Mohammad Reda Katby
 
ZIP
Decorator pattern
jacobfrericks
 
PPTX
Software Patterns
bonej010
 
PDF
Software Architecture: Principles, Patterns and Practices
Ganesh Samarthyam
 
PPTX
Decorator Design Pattern
Adeel Riaz
 
PDF
Decorator design pattern (A Gift Wrapper)
Sameer Rathoud
 
PPTX
Decorator Pattern presentation theory and examples
abrahamjuradoaguiler2
 
PDF
Applying Design Principles in Practice
Tushar Sharma
 
Design patterns structuralpatterns(thedecoratorpattern)
APU
 
Decorator Design Pattern
Kanushka Gayan
 
Decorator design pattern
Neelima Sanagavarapu
 
Decorator Pattern 2.pptxdsadsadsadsadasdasdsa
baocongle204
 
10-DesignPatterns.ppt
TAGADPALLEWARPARTHVA
 
Design patterns represent the best practices used by experienced object-orien...
nevanak569
 
Structure-Decorator deign pattern model fact
mdimberu
 
DECORATOR PATTERN IN WEB APPLICATION Design
ijait
 
DECORATOR PATTERN IN WEB APPLICATION
ijait
 
Stoop 439-decorator
The World of Smalltalk
 
Omg! Patterns <decorator> by Max Titov
Max Titov
 
Design Patterns Part1
Tom Chen
 
Decorator pattern
Mohammad Reda Katby
 
Decorator pattern
jacobfrericks
 
Software Patterns
bonej010
 
Software Architecture: Principles, Patterns and Practices
Ganesh Samarthyam
 
Decorator Design Pattern
Adeel Riaz
 
Decorator design pattern (A Gift Wrapper)
Sameer Rathoud
 
Decorator Pattern presentation theory and examples
abrahamjuradoaguiler2
 
Applying Design Principles in Practice
Tushar Sharma
 
Ad

Recently uploaded (20)

PDF
Add Background Images to Charts in IBM SPSS Statistics Version 31.pdf
Version 1 Analytics
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
Adobe Premiere Pro Crack / Full Version / Free Download
hashhshs786
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Add Background Images to Charts in IBM SPSS Statistics Version 31.pdf
Version 1 Analytics
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Adobe Premiere Pro Crack / Full Version / Free Download
hashhshs786
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Ad

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