SlideShare a Scribd company logo
DESIGN PATTERN
READING GROUP –
DECORATOR PATTERN
2014/May/30
Vincent Chu
AGENDA
What is Decorator Pattern?
Examples
Conclusion
WHAT IS DECORATOR
PATTERN?
Definition
In object-oriented
programming, the
decorator pattern (also
known as Wrapper, an
alternative naming shared
with the Adapter pattern)
is a design pattern that
allows behavior to be
added to an individual
object, either statically or
dynamically, without
affecting the behavior of
other objects from the
same class.
UML
WHAT IS DECORATOR
PATTERN?
Implementation
1. Subclass the original "Component" class into a
"Decorator" class (see UML diagram);
2. In the Decorator class, add a Component pointer as a
field;
3. Pass a Component to the Decorator constructor to
initialize the Component pointer;
4. In the Decorator class, redirect all "Component"
methods to the "Component" pointer; and
5. In the ConcreteDecorator class, override any
Component method(s) whose behavior needs to be
modified.
EXAMPLES
Cup of Joe Beauty Salon
EXAMPLE – COFFEE
EXAMPLE – BEAUTY SALON
http://www.slideshare.net/eolexe/omg-patterns-
ltdecorator-by-max-titov
Page 3
CONCLUSION
Consider following pattern before you choice Decorator
 Adapter
 Proxy
 Strategy
 Composite
CONCLUSION
Pros
1) The cure of ugly code
2) Composition over
inheritance
3) Add behavior at runtime
without class
modification
4) Behavior can be reuse
Cons
1) Tons of small classes
2) Could be not obvious for
other developers
REFERENCE
Wikipedia -
http://en.wikipedia.org/wiki/Decorator_pattern
Photo & Conclusion -
http://www.slideshare.net/eprafulla/01-introduction-
and-decorator-pattern
Beauty Salon - http://www.slideshare.net/eolexe/omg-
patterns-ltdecorator-by-max-titov
Cup of Joe -
http://www.slideshare.net/melbournepatterns/phani-
kumar-decorator-pattern
Coffee -
http://internshipblogg.wordpress.com/2012/06/13/dec
orator-pattern-power-of-extension/
THANKS FOR YOUR TIME!

More Related Content

What's hot

Decorator Design Pattern
Decorator Design PatternDecorator Design Pattern
Decorator Design Pattern
Adeel Riaz
 
What is design pattern
What is design patternWhat is design pattern
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
Shahriar Hyder
 
Bridge pattern
Bridge patternBridge pattern
Bridge pattern
Shakil Ahmed
 
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
Sergey Aganezov
 
Application Of Software Design Pattern
Application Of Software Design PatternApplication Of Software Design Pattern
Application Of Software Design Patternguest46da5428
 
Object oriented design
Object oriented designObject oriented design
Object oriented design
Mohammad Reda Katby
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
Michael Heron
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
naveen kumar
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
Sanae BEKKAR
 
The SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design PatternsThe SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design Patterns
Hayim Makabee
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
Shahzad
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade Pattern
Mudasir Qazi
 
Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)
paramisoft
 
Bai giang-uml-11feb14
Bai giang-uml-11feb14Bai giang-uml-11feb14
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design Pattern
Nishith Shukla
 
Bridge pattern for Dummies
Bridge pattern for DummiesBridge pattern for Dummies
Bridge pattern for Dummies
TaekSoon Jang
 

What's hot (20)

Decorator Design Pattern
Decorator Design PatternDecorator Design Pattern
Decorator Design Pattern
 
What is design pattern
What is design patternWhat is design pattern
What is design pattern
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
 
Bridge pattern
Bridge patternBridge pattern
Bridge 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
 
Application Of Software Design Pattern
Application Of Software Design PatternApplication Of Software Design Pattern
Application Of Software Design Pattern
 
Object oriented design
Object oriented designObject oriented design
Object oriented design
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
Bridge Pattern Derek Weeks
Bridge Pattern   Derek WeeksBridge Pattern   Derek Weeks
Bridge Pattern Derek Weeks
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
 
The SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design PatternsThe SOLID Principles Illustrated by Design Patterns
The SOLID Principles Illustrated by Design Patterns
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade Pattern
 
Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)
 
Bai giang-uml-11feb14
Bai giang-uml-11feb14Bai giang-uml-11feb14
Bai giang-uml-11feb14
 
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design Pattern
 
Bridge pattern for Dummies
Bridge pattern for DummiesBridge pattern for Dummies
Bridge pattern for Dummies
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 
Composite Design Pattern
Composite Design PatternComposite Design Pattern
Composite Design Pattern
 

Viewers also liked

ديوان الإمام الشافعي مع مختارات من روائع حكمه
ديوان الإمام الشافعي مع مختارات من روائع حكمهديوان الإمام الشافعي مع مختارات من روائع حكمه
ديوان الإمام الشافعي مع مختارات من روائع حكمه
Ramzi Mandhouj
 
قصص الصحابة و الصالحين . محمد متولي الشعراوي . مكتبة أبوالعيس
قصص الصحابة و الصالحين . محمد متولي الشعراوي . مكتبة أبوالعيسقصص الصحابة و الصالحين . محمد متولي الشعراوي . مكتبة أبوالعيس
قصص الصحابة و الصالحين . محمد متولي الشعراوي . مكتبة أبوالعيس
PUSH BUTTIONS
 
Reading group schedule
Reading group scheduleReading group schedule
Reading group scheduleEmily Lobao
 
Reading Group Presentation
Reading Group PresentationReading Group Presentation
Reading Group PresentationJia
 
Skillwise Consulting_Soft skills
Skillwise Consulting_Soft skillsSkillwise Consulting_Soft skills
Skillwise Consulting_Soft skills
Skillwise Consulting
 
2 types of businesses business studies
2 types of businesses business studies2 types of businesses business studies
2 types of businesses business studies
Phoebe Riorden
 
Computer Fundamental
Computer FundamentalComputer Fundamental
Computer Fundamental
JAI MCA-STUDENT
 
Power point
Power pointPower point
Power pointwiratra
 
Fundraising Planning Worksheet
Fundraising Planning WorksheetFundraising Planning Worksheet
Fundraising Planning Worksheet
4Good.org
 

Viewers also liked (9)

ديوان الإمام الشافعي مع مختارات من روائع حكمه
ديوان الإمام الشافعي مع مختارات من روائع حكمهديوان الإمام الشافعي مع مختارات من روائع حكمه
ديوان الإمام الشافعي مع مختارات من روائع حكمه
 
قصص الصحابة و الصالحين . محمد متولي الشعراوي . مكتبة أبوالعيس
قصص الصحابة و الصالحين . محمد متولي الشعراوي . مكتبة أبوالعيسقصص الصحابة و الصالحين . محمد متولي الشعراوي . مكتبة أبوالعيس
قصص الصحابة و الصالحين . محمد متولي الشعراوي . مكتبة أبوالعيس
 
Reading group schedule
Reading group scheduleReading group schedule
Reading group schedule
 
Reading Group Presentation
Reading Group PresentationReading Group Presentation
Reading Group Presentation
 
Skillwise Consulting_Soft skills
Skillwise Consulting_Soft skillsSkillwise Consulting_Soft skills
Skillwise Consulting_Soft skills
 
2 types of businesses business studies
2 types of businesses business studies2 types of businesses business studies
2 types of businesses business studies
 
Computer Fundamental
Computer FundamentalComputer Fundamental
Computer Fundamental
 
Power point
Power pointPower point
Power point
 
Fundraising Planning Worksheet
Fundraising Planning WorksheetFundraising Planning Worksheet
Fundraising Planning Worksheet
 

Similar to Design pattern reading group – decorator pattern

Design Patterns
Design PatternsDesign Patterns
Design Patterns
adil raja
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
Amit Kabra
 
Andy Bulka Pattern Automation
Andy Bulka Pattern AutomationAndy Bulka Pattern Automation
Andy Bulka Pattern Automationtcab22
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
Dr. C.V. Suresh Babu
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The World
Saurabh Moody
 
Refactoring: Code it Clean
Refactoring: Code it CleanRefactoring: Code it Clean
Refactoring: Code it Clean
AliGermiyanoglu
 
L05 Frameworks
L05 FrameworksL05 Frameworks
L05 Frameworks
Ólafur Andri Ragnarsson
 
Design pattern in an expressive language java script
Design pattern in an expressive language java scriptDesign pattern in an expressive language java script
Design pattern in an expressive language java scriptAmit Thakkar
 
Software architecture with SOA modeling Flavor
Software architecture with SOA modeling FlavorSoftware architecture with SOA modeling Flavor
Software architecture with SOA modeling Flavor
Mohamed Zakarya Abdelgawad
 
uml reference package_diagram
uml reference package_diagramuml reference package_diagram
uml reference package_diagram
Mohamed Zakarya Abdelgawad
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
Mindfire Solutions
 
P Training Presentation
P Training PresentationP Training Presentation
P Training PresentationGaurav Tyagi
 
Software engineering: design for reuse
Software engineering: design for reuseSoftware engineering: design for reuse
Software engineering: design for reuseMarco Brambilla
 
Apply Template Method Pattern in Report Implementation
Apply Template Method Pattern in Report ImplementationApply Template Method Pattern in Report Implementation
Apply Template Method Pattern in Report ImplementationGuo Albert
 
Angular2
Angular2Angular2
Design Patterns
Design PatternsDesign Patterns
Design Patterns
imedo.de
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design Pattern
ProdigyView
 
Design patterns
Design patternsDesign patterns
Design patterns
mudabbirwarsi
 
ITSE_10(UML,OO).pptx
ITSE_10(UML,OO).pptxITSE_10(UML,OO).pptx
ITSE_10(UML,OO).pptx
mubashirahmed0296
 

Similar to Design pattern reading group – decorator pattern (20)

Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
 
Andy Bulka Pattern Automation
Andy Bulka Pattern AutomationAndy Bulka Pattern Automation
Andy Bulka Pattern Automation
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The World
 
Refactoring: Code it Clean
Refactoring: Code it CleanRefactoring: Code it Clean
Refactoring: Code it Clean
 
L05 Frameworks
L05 FrameworksL05 Frameworks
L05 Frameworks
 
Design pattern in an expressive language java script
Design pattern in an expressive language java scriptDesign pattern in an expressive language java script
Design pattern in an expressive language java script
 
Software architecture with SOA modeling Flavor
Software architecture with SOA modeling FlavorSoftware architecture with SOA modeling Flavor
Software architecture with SOA modeling Flavor
 
uml reference package_diagram
uml reference package_diagramuml reference package_diagram
uml reference package_diagram
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
 
Software engineering: design for reuse
Software engineering: design for reuseSoftware engineering: design for reuse
Software engineering: design for reuse
 
Apply Template Method Pattern in Report Implementation
Apply Template Method Pattern in Report ImplementationApply Template Method Pattern in Report Implementation
Apply Template Method Pattern in Report Implementation
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
Angular2
Angular2Angular2
Angular2
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design Pattern
 
Design patterns
Design patternsDesign patterns
Design patterns
 
ITSE_10(UML,OO).pptx
ITSE_10(UML,OO).pptxITSE_10(UML,OO).pptx
ITSE_10(UML,OO).pptx
 

Recently uploaded

Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

Design pattern reading group – decorator pattern

  • 1. DESIGN PATTERN READING GROUP – DECORATOR PATTERN 2014/May/30 Vincent Chu
  • 2. AGENDA What is Decorator Pattern? Examples Conclusion
  • 3. WHAT IS DECORATOR PATTERN? Definition In object-oriented programming, the decorator pattern (also known as Wrapper, an alternative naming shared with the Adapter pattern) is a design pattern that allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class. UML
  • 4. WHAT IS DECORATOR PATTERN? Implementation 1. Subclass the original "Component" class into a "Decorator" class (see UML diagram); 2. In the Decorator class, add a Component pointer as a field; 3. Pass a Component to the Decorator constructor to initialize the Component pointer; 4. In the Decorator class, redirect all "Component" methods to the "Component" pointer; and 5. In the ConcreteDecorator class, override any Component method(s) whose behavior needs to be modified.
  • 5. EXAMPLES Cup of Joe Beauty Salon
  • 7. EXAMPLE – BEAUTY SALON http://www.slideshare.net/eolexe/omg-patterns- ltdecorator-by-max-titov Page 3
  • 8. CONCLUSION Consider following pattern before you choice Decorator  Adapter  Proxy  Strategy  Composite
  • 9. CONCLUSION Pros 1) The cure of ugly code 2) Composition over inheritance 3) Add behavior at runtime without class modification 4) Behavior can be reuse Cons 1) Tons of small classes 2) Could be not obvious for other developers
  • 10. REFERENCE Wikipedia - http://en.wikipedia.org/wiki/Decorator_pattern Photo & Conclusion - http://www.slideshare.net/eprafulla/01-introduction- and-decorator-pattern Beauty Salon - http://www.slideshare.net/eolexe/omg- patterns-ltdecorator-by-max-titov Cup of Joe - http://www.slideshare.net/melbournepatterns/phani- kumar-decorator-pattern Coffee - http://internshipblogg.wordpress.com/2012/06/13/dec orator-pattern-power-of-extension/