
Decorator Pattern in Software Design
Explore the concepts of Observer Decorators, Inheritance Models, and Coffee Design Patterns in software development. Dive into the principles, advantages, and downsides of using decorators in your projects. Develop a solid understanding of when and how to implement decorators effectively.
Uploaded on | 1 Views
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Week 4, Day 3: Observer Decorators Muddiest Point Half Exam 1 on Thursday SE-2811 1 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder
Coffee Inheritance Model Design Review Any potential changes? Keep current design? SE-2811 2 Dr. Mark L. Hornick
Time for Coffee 2.0 Want to be able to add, Whip, Mocha, DarkRoast, etc. to our coffee Exercise: With your team, create a design to include these decorators and have the cost function return their cost SE-2811 3 Dr. Mark L. Hornick
One approach: Inheritance SE-2811 4 Dr. Mark L. Hornick
Cleaned up with decorator pattern SE-2811 5 Dr. Mark L. Hornick
Cost of DarkRoast with Whip and Mocha cost() cost() cost() 0.10 0.20 0.99 $1.29 DarkRoast Mocha Whip SE-2811 6 Dr. Mark L. Hornick
General Pattern SE-2811 7 Dr. Mark L. Hornick Wikipedia
Example 2: Byte Input Streams SE-2811 8 Dr. Mark L. Hornick
Ex 3: Bikes SE-2811 9 Dr. Mark L. Hornick
Ex 4: Employees SE-2811 10 Dr. Mark L. Hornick http://zishanbilal.files.wordpress.com/2011/04/042811_2030_designpatte31.png
Design Principles Reduce coupling Increase cohesion Encapsulate what varies Favor composition over inheritance Program to interfaces, not implementations Classes should be open for extension but closed for modification Which of these are met? SE-2811 11 Dr. Mark L. Hornick
Downsides What are the disadvantages of decorators? SE-2811 12 Dr. Mark L. Hornick
SE-2811 13 Dr. Mark L. Hornick