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

PPTX
Decorator Pattern
PPTX
Design Patterns - 01 Introduction and Decorator Pattern
PPTX
Decorator design pattern
PDF
Decorator & Presenter Design Pattern
PPTX
Design pattern reading group – decorator pattern
PPTX
Bridge Design Pattern
PPS
Bridge Pattern Derek Weeks
PDF
Bridge pattern for Dummies
Decorator Pattern
Design Patterns - 01 Introduction and Decorator Pattern
Decorator design pattern
Decorator & Presenter Design Pattern
Design pattern reading group – decorator pattern
Bridge Design Pattern
Bridge Pattern Derek Weeks
Bridge pattern for Dummies

What's hot (20)

PPT
Bridge pattern
PPTX
Design Pattern - Introduction
PPTX
Design pattern - Facade Pattern
PPTX
Facade Pattern
PPTX
Creational pattern
PPT
Facade pattern
PPTX
Design Pattern
PPTX
Facade pattern presentation(.pptx)
PDF
Software Design Patterns. Part I :: Structural Patterns
PPTX
Class diagram
PDF
Solid principles, Design Patterns, and Domain Driven Design
ODP
Bridge
PDF
Gof design pattern
PPTX
The Ultimate Guide for UML Class Diagrams by Creately
PPT
Composite Design Pattern
PPT
Uml struct2
PPT
Object and class relationships
PPTX
Class and object_diagram
PPTX
Design pattern - Software Engineering
PPTX
PATTERNS04 - Structural Design Patterns
Bridge pattern
Design Pattern - Introduction
Design pattern - Facade Pattern
Facade Pattern
Creational pattern
Facade pattern
Design Pattern
Facade pattern presentation(.pptx)
Software Design Patterns. Part I :: Structural Patterns
Class diagram
Solid principles, Design Patterns, and Domain Driven Design
Bridge
Gof design pattern
The Ultimate Guide for UML Class Diagrams by Creately
Composite Design Pattern
Uml struct2
Object and class relationships
Class and object_diagram
Design pattern - Software Engineering
PATTERNS04 - Structural Design Patterns
Ad

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

PPTX
Architecture and design
PDF
UML-Advanced Software Engineering
PDF
OOM Unit I - III.pdf
PDF
Object oriented analysis and design unit- iv
PPTX
Software Patterns
PPTX
Design patterns
PPT
Software Design Patterns
PPT
Software Design Patterns
PPT
chapter 5 Objectdesign.ppt
PDF
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
PPT
Introduction to Rational Rose
PPT
Uml - An Overview
PPTX
PPTX
Facadepattern
PPT
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
PPT
Facade pattern
PPTX
Object_Oriented_Design_Class and Object Diagrams.pptx
PDF
Software Designing - Software Engineering
PPT
Introduction To Design Patterns
PPTX
Design pattern (week 2)
Architecture and design
UML-Advanced Software Engineering
OOM Unit I - III.pdf
Object oriented analysis and design unit- iv
Software Patterns
Design patterns
Software Design Patterns
Software Design Patterns
chapter 5 Objectdesign.ppt
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
Introduction to Rational Rose
Uml - An Overview
Facadepattern
Software Architecture and Project Management module III : PATTERN OF ENTERPRISE
Facade pattern
Object_Oriented_Design_Class and Object Diagrams.pptx
Software Designing - Software Engineering
Introduction To Design Patterns
Design pattern (week 2)
Ad

Recently uploaded (20)

PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Digital Strategies for Manufacturing Companies
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Navsoft: AI-Powered Business Solutions & Custom Software Development
Odoo Companies in India – Driving Business Transformation.pdf
Reimagine Home Health with the Power of Agentic AI​
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Digital Strategies for Manufacturing Companies
How to Choose the Right IT Partner for Your Business in Malaysia
Understanding Forklifts - TECH EHS Solution
VVF-Customer-Presentation2025-Ver1.9.pptx
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Softaken Excel to vCard Converter Software.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Upgrade and Innovation Strategies for SAP ERP Customers

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