SlideShare uma empresa Scribd logo
1 de 21
Decorator Pattern
Design Patterns
Tharuka Dilani Siriwardena.
M.A.N.Shahitha Nazrin.
S.P Dimuthu Anuraj.
INTRODUCTION
DESIGN PATTERNS - DEFINITION
• A general reusable solution to a commonly occurring
problem in software design (Wikipedia).
• It is not a finished design.
• It is a description or template for how to solve a problem
that can be used in many different situations.
• Shows relationship and interactions between classes
and/or objects.
DESIGN PATTERNS - CLASSIFICATION
• Creational pattern
• Deal with object creation mechanism
• E.g. Abstract Factory, Singleton
• Structural pattern
• Ease the design by identifying a simple way to realize relationships
between entities
• E.g. Decorator, Proxy
• Behavioral pattern
• Deal with common communication between objects.
• E.g. Chain of Responsibility, Command
DESIGN PATTERNS – CLASSIFICATION
Structural Patterns
• 1. Decorator
• 2. Proxy
• 3. Bridge
• 4. Composite
• 5. Flyweight
• 6. Adapter
• 7. Facade
Creational Patterns
• 1. Prototype
• 2. Factory Method
• 3. Singleton
• 4. Abstract Factory
• 5. Builder
Behavioral Patterns
• 1. Strategy
• 2. State
• 3. TemplateMethod
• 4. Chain of
Responsibility
• 5. Command
• 6. Iterator
• 7. Mediator
• 8. Observer
• 9. Visitor
• 10. Interpreter
• 11. Memento
Decorator
Structural Design Pattern
CONCEPT OF DECORATING IN REAL
WORLD
Before Decorating
After Decorating
DEFINITION
• In object-oriented programming, the decorator
pattern is a design pattern that allows new/additional
behaviour to be added to an existing object dynamically.
Photo
+
Frame
+
Caption
RAD Family
DECORATOR PATTERN - EXPLAINED
• Adds functionality at Runtime.
• The object does not know it is being “decorated”.
• Three is no one big feature-laden class with all the
options in it.
• The decorations are independent of each other.
• The decorations can be composed together in a mix-
and-match fashion.
DECORATOR PATTERN - EXPLAINED
IMPLEMENTATION
• We're going to create a Shape interface and concrete classes
implementing the Shape interface. We will then create an
abstract decorator class ShapeDecorator implementing the
Shape interface and having Shape object as its instance
variable.
• RedShapeDecorator is concrete class implementing
ShapeDecorator.
• DecoratorPatternDemo, our demo class will use
RedShapeDecorator to decorate Shape objects.
DECORATOR PATTERN - UML
DIAGRAM
DEMO
Builder Pattern Decorator Pattern
• Graphics world (as illustrated).
• I/O namespace of .NET
• System.IO.Stream
• System.IO.BufferedStream
• System.IO.FileStream
• System.IO.MemoryStream
• Cross platform applications (Mobile/Desktop)
• Actual decorator classes in .NET 3.0
• System.Windows.Controls (Base Class)
• Border (Decorator)
• Viewbox (Decorator)
DECORATOR PATTERN – REAL WORLD
SAMPLE
• You have:
• An existing component class that may be unavailable for
subclassing.
• You want to:
• Attach additional state or behavior to an object dynamically.
• Make Changes to some objects of a class without affecting
others.
• Avoid subclassing because too many classes could result.
DECORATOR PATTERN – GUIDELINES(1)
• But consider using instead:
• The Adapter Pattern
• Sets up an interface between different classes
• The Composite Pattern
• Aggregates an object without also inheriting its interface.
• The Proxy Pattern
• Specifically controls access to objects.
• The Strategy Pattern
• Changes the original object rather than wrapping it.
DECORATOR PATTERN – GUIDELINES(2)
BUILDER VS DECORATOR
• Builder patterns makes it easy
to construct an object which
is extensible in independent
directions at construction
time
• Decorator pattern lets you
add extensions to
functionality to an object after
construction time
BUILDER VS DECORATOR
• Builder
Elements are must
This acts as a base on top other work
if this fails the object will be incomplete or inconsistent
• Decorator
Elements are optional
This is to add/attach more responsibility to existing
object
This is bonus or extra functionality is won’t affect the
basic behavior
Thank You !
ANY QUESTIONS?
Decorator Pattern

Mais conteúdo relacionado

Mais procurados

Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patternsAmit Kabra
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Patternguy_davis
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns pptAman Jain
 
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan GoleChetan Gole
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern PresentationJAINIK PATEL
 
Java Course 11: Design Patterns
Java Course 11: Design PatternsJava Course 11: Design Patterns
Java Course 11: Design PatternsAnton Keks
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software EngineeringManish Kumar
 
Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - AdapterManoj Kumar
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design PatternSanae BEKKAR
 

Mais procurados (20)

Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 
Builder pattern
Builder patternBuilder pattern
Builder pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan Gole
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
 
Adapter pattern
Adapter patternAdapter pattern
Adapter pattern
 
Decorator design pattern
Decorator design patternDecorator design pattern
Decorator design pattern
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
What is design pattern
What is design patternWhat is design pattern
What is design pattern
 
Facade pattern
Facade patternFacade pattern
Facade pattern
 
Design pattern
Design patternDesign pattern
Design pattern
 
Java Course 11: Design Patterns
Java Course 11: Design PatternsJava Course 11: Design Patterns
Java Course 11: Design Patterns
 
Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software Engineering
 
Composite pattern
Composite patternComposite pattern
Composite pattern
 
Structural Design pattern - Adapter
Structural Design pattern - AdapterStructural Design pattern - Adapter
Structural Design pattern - Adapter
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
 

Destaque

Markerless inspection of ar using fingertip tracking
Markerless inspection of ar using fingertip trackingMarkerless inspection of ar using fingertip tracking
Markerless inspection of ar using fingertip trackingTharuka Siriwardena
 
Implementation of composite design pattern in android view and widgets
Implementation of composite design pattern in android view and widgetsImplementation of composite design pattern in android view and widgets
Implementation of composite design pattern in android view and widgetsSomenath Mukhopadhyay
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator PatternAkshat Vig
 
Observer and Decorator Pattern
Observer and Decorator PatternObserver and Decorator Pattern
Observer and Decorator PatternJonathan Simon
 
Design Patterns - 04 Adapter and Facade Pattern
Design Patterns - 04 Adapter and Facade PatternDesign Patterns - 04 Adapter and Facade Pattern
Design Patterns - 04 Adapter and Facade Patterneprafulla
 
урок 51 річки
урок 51 річкиурок 51 річки
урок 51 річкиvyglinska
 
Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 
Adobe Illustrator - Урок 2
Adobe Illustrator - Урок 2Adobe Illustrator - Урок 2
Adobe Illustrator - Урок 2RaynaITSTEP
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer GraphicsSanu Philip
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: AndroidJitendra Kumar
 
Ghanshyam avenue
Ghanshyam avenueGhanshyam avenue
Ghanshyam avenueSachin Jain
 
внутрішні води євразії
внутрішні води  євразіївнутрішні води  євразії
внутрішні води євразіїvyglinska
 
Monografia final Sistema Controle de Estoque
Monografia final Sistema Controle de EstoqueMonografia final Sistema Controle de Estoque
Monografia final Sistema Controle de EstoqueInacioBelo
 

Destaque (18)

Markerless inspection of ar using fingertip tracking
Markerless inspection of ar using fingertip trackingMarkerless inspection of ar using fingertip tracking
Markerless inspection of ar using fingertip tracking
 
Implementation of composite design pattern in android view and widgets
Implementation of composite design pattern in android view and widgetsImplementation of composite design pattern in android view and widgets
Implementation of composite design pattern in android view and widgets
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator Pattern
 
Design pattern
Design patternDesign pattern
Design pattern
 
Observer and Decorator Pattern
Observer and Decorator PatternObserver and Decorator Pattern
Observer and Decorator Pattern
 
Composite Design Pattern
Composite Design PatternComposite Design Pattern
Composite Design Pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Design Patterns - 04 Adapter and Facade Pattern
Design Patterns - 04 Adapter and Facade PatternDesign Patterns - 04 Adapter and Facade Pattern
Design Patterns - 04 Adapter and Facade Pattern
 
Testamen
TestamenTestamen
Testamen
 
Apostila usinagem
Apostila usinagemApostila usinagem
Apostila usinagem
 
урок 51 річки
урок 51 річкиурок 51 річки
урок 51 річки
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Adobe Illustrator - Урок 2
Adobe Illustrator - Урок 2Adobe Illustrator - Урок 2
Adobe Illustrator - Урок 2
 
Projection In Computer Graphics
Projection In Computer GraphicsProjection In Computer Graphics
Projection In Computer Graphics
 
Architectural Design Pattern: Android
Architectural Design Pattern: AndroidArchitectural Design Pattern: Android
Architectural Design Pattern: Android
 
Ghanshyam avenue
Ghanshyam avenueGhanshyam avenue
Ghanshyam avenue
 
внутрішні води євразії
внутрішні води  євразіївнутрішні води  євразії
внутрішні води євразії
 
Monografia final Sistema Controle de Estoque
Monografia final Sistema Controle de EstoqueMonografia final Sistema Controle de Estoque
Monografia final Sistema Controle de Estoque
 

Semelhante a Decorator Pattern

Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2Julie Iskander
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptRushikeshChikane1
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptRushikeshChikane2
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxanguraju1
 
the Modeling is a way of thinking about the
the Modeling is a way of thinking about thethe Modeling is a way of thinking about the
the Modeling is a way of thinking about thesaman zaker
 
Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptxSachin Patidar
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)stanbridge
 
P Training Presentation
P Training PresentationP Training Presentation
P Training PresentationGaurav Tyagi
 
Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Heartin Jacob
 
Code Like a Ninja Session 8 - Structural Design Patterns
Code Like a Ninja Session 8 - Structural Design PatternsCode Like a Ninja Session 8 - Structural Design Patterns
Code Like a Ninja Session 8 - Structural Design PatternsDeon Meyer
 
Design pattern
Design patternDesign pattern
Design patternOmar Isaid
 
SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"Inhacking
 
Design Patterns In Scala
Design Patterns In ScalaDesign Patterns In Scala
Design Patterns In ScalaKnoldus Inc.
 
Design patterns Structural
Design patterns StructuralDesign patterns Structural
Design patterns StructuralUMAR ALI
 
Software enginering.group-no-11 (1)
Software enginering.group-no-11 (1)Software enginering.group-no-11 (1)
Software enginering.group-no-11 (1)riarana10
 
Gang of Four in Java
Gang of Four in Java Gang of Four in Java
Gang of Four in Java Mina Tafreshi
 

Semelhante a Decorator Pattern (20)

Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
 
the Modeling is a way of thinking about the
the Modeling is a way of thinking about thethe Modeling is a way of thinking about the
the Modeling is a way of thinking about the
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptx
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
 
Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)
 
Code Like a Ninja Session 8 - Structural Design Patterns
Code Like a Ninja Session 8 - Structural Design PatternsCode Like a Ninja Session 8 - Structural Design Patterns
Code Like a Ninja Session 8 - Structural Design Patterns
 
Design pattern
Design patternDesign pattern
Design pattern
 
SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"
 
Alex Theedom Java ee revisits design patterns
Alex Theedom	Java ee revisits design patternsAlex Theedom	Java ee revisits design patterns
Alex Theedom Java ee revisits design patterns
 
Design Patterns In Scala
Design Patterns In ScalaDesign Patterns In Scala
Design Patterns In Scala
 
Design patterns Structural
Design patterns StructuralDesign patterns Structural
Design patterns Structural
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
Software enginering.group-no-11 (1)
Software enginering.group-no-11 (1)Software enginering.group-no-11 (1)
Software enginering.group-no-11 (1)
 
Decorator pattern
Decorator patternDecorator pattern
Decorator pattern
 
Gang of Four in Java
Gang of Four in Java Gang of Four in Java
Gang of Four in Java
 

Último

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 

Último (20)

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 

Decorator Pattern

  • 1. Decorator Pattern Design Patterns Tharuka Dilani Siriwardena. M.A.N.Shahitha Nazrin. S.P Dimuthu Anuraj.
  • 3. DESIGN PATTERNS - DEFINITION • A general reusable solution to a commonly occurring problem in software design (Wikipedia). • It is not a finished design. • It is a description or template for how to solve a problem that can be used in many different situations. • Shows relationship and interactions between classes and/or objects.
  • 4. DESIGN PATTERNS - CLASSIFICATION • Creational pattern • Deal with object creation mechanism • E.g. Abstract Factory, Singleton • Structural pattern • Ease the design by identifying a simple way to realize relationships between entities • E.g. Decorator, Proxy • Behavioral pattern • Deal with common communication between objects. • E.g. Chain of Responsibility, Command
  • 5. DESIGN PATTERNS – CLASSIFICATION Structural Patterns • 1. Decorator • 2. Proxy • 3. Bridge • 4. Composite • 5. Flyweight • 6. Adapter • 7. Facade Creational Patterns • 1. Prototype • 2. Factory Method • 3. Singleton • 4. Abstract Factory • 5. Builder Behavioral Patterns • 1. Strategy • 2. State • 3. TemplateMethod • 4. Chain of Responsibility • 5. Command • 6. Iterator • 7. Mediator • 8. Observer • 9. Visitor • 10. Interpreter • 11. Memento
  • 7. CONCEPT OF DECORATING IN REAL WORLD Before Decorating After Decorating
  • 8. DEFINITION • In object-oriented programming, the decorator pattern is a design pattern that allows new/additional behaviour to be added to an existing object dynamically.
  • 10. • Adds functionality at Runtime. • The object does not know it is being “decorated”. • Three is no one big feature-laden class with all the options in it. • The decorations are independent of each other. • The decorations can be composed together in a mix- and-match fashion. DECORATOR PATTERN - EXPLAINED
  • 12. • We're going to create a Shape interface and concrete classes implementing the Shape interface. We will then create an abstract decorator class ShapeDecorator implementing the Shape interface and having Shape object as its instance variable. • RedShapeDecorator is concrete class implementing ShapeDecorator. • DecoratorPatternDemo, our demo class will use RedShapeDecorator to decorate Shape objects.
  • 13. DECORATOR PATTERN - UML DIAGRAM
  • 15. • Graphics world (as illustrated). • I/O namespace of .NET • System.IO.Stream • System.IO.BufferedStream • System.IO.FileStream • System.IO.MemoryStream • Cross platform applications (Mobile/Desktop) • Actual decorator classes in .NET 3.0 • System.Windows.Controls (Base Class) • Border (Decorator) • Viewbox (Decorator) DECORATOR PATTERN – REAL WORLD SAMPLE
  • 16. • You have: • An existing component class that may be unavailable for subclassing. • You want to: • Attach additional state or behavior to an object dynamically. • Make Changes to some objects of a class without affecting others. • Avoid subclassing because too many classes could result. DECORATOR PATTERN – GUIDELINES(1)
  • 17. • But consider using instead: • The Adapter Pattern • Sets up an interface between different classes • The Composite Pattern • Aggregates an object without also inheriting its interface. • The Proxy Pattern • Specifically controls access to objects. • The Strategy Pattern • Changes the original object rather than wrapping it. DECORATOR PATTERN – GUIDELINES(2)
  • 18. BUILDER VS DECORATOR • Builder patterns makes it easy to construct an object which is extensible in independent directions at construction time • Decorator pattern lets you add extensions to functionality to an object after construction time
  • 19. BUILDER VS DECORATOR • Builder Elements are must This acts as a base on top other work if this fails the object will be incomplete or inconsistent • Decorator Elements are optional This is to add/attach more responsibility to existing object This is bonus or extra functionality is won’t affect the basic behavior
  • 20. Thank You ! ANY QUESTIONS?