Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 5, Day 2: Decorator Decorators Muddiest Point Tomorrow: Quiz on lab reading: https://faculty- web.msoe.edu/hasker/se2811/labs/5/ SE-2811 Slide design:

Similar presentations


Presentation on theme: "Week 5, Day 2: Decorator Decorators Muddiest Point Tomorrow: Quiz on lab reading: https://faculty- web.msoe.edu/hasker/se2811/labs/5/ SE-2811 Slide design:"— Presentation transcript:

1 Week 5, Day 2: Decorator Decorators Muddiest Point Tomorrow: Quiz on lab reading: https://faculty- web.msoe.edu/hasker/se2811/labs/5/ SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder 1

2 Coffee Inheritance Model Design Review Any potential changes? Keep current design? SE-2811 Dr. Mark L. Hornick 2

3 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 Dr. Mark L. Hornick 3

4 One approach: Inheritance SE-2811 Dr. Mark L. Hornick 4

5 Cleaned up with decorator pattern SE-2811 Dr. Mark L. Hornick 5

6 Cost of DarkRoast with Whip and Mocha SE-2811 Dr. Mark L. Hornick 6 Whip Mocha DarkRoast cost() 0.99 0.20 0.10 $1.29

7 General Pattern SE-2811 Dr. Mark L. Hornick Wikipedia 7

8 Example 2: Byte Input Streams SE-2811 Dr. Mark L. Hornick 8

9 Ex 3: Bikes SE-2811 Dr. Mark L. Hornick 9

10 Ex 4: Employees SE-2811 Dr. Mark L. Hornick http://zishanbilal.files.wordpress.com/2011/04/042811_2030_designpatte31.png 10

11 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 Dr. Mark L. Hornick 11

12 Downsides What are the disadvantages of decorators? SE-2811 Dr. Mark L. Hornick 12

13 SE-2811 Dr. Mark L. Hornick 13

14 Knowing that the input stream classes are based on the Decorator pattern can make things easier SE-2811 Dr. Mark L. Hornick 14 >

15 The Decorator pattern applied to output streams SE-2811 Dr. Mark L. Hornick 15 (with other Variables…)

16 Threading Muddiest Point [To be revisited in a future lecture] All lambda examples the same code? Lambda examples When would you use a Lambda expression over an anonymous class and vice versa? Lambda vs. Anon inner syntax The Lambda is a Java thing, not an intelliJ thing right?Java 8 whens the next quiz?Quiz Agree Lambda examples More examples of using lambdas (didn't get exposure in software dev 2) Lambda examples Effectively Final? "Effectively Final" SE-2811 Dr. Mark L. Hornick 16

17 Patterns Muddiest Point [To be revisited in a future leture] We really didn't cover any sorting algorithms and what each's benefits are Can we do an example??? Related to the quiz for below question Do we need to implement code versions of the strategy and factory method patterns?? If so how extensive and will it be similar to how we implemented in class? Implementing the methods needed for the factory method pattern. Is there a flowchart/checklist to determine which pattern is more appropriate to use? Choosing the correct design pattern What are Coupling and Cohesion and is it better to have high or low coupling or cohesion? On a quiz/test would you ask us to draw the uml of a particular general pattern, or would you just ask us to write the code? Why would we use Factory Pattern? How do you know when to use what pattern to solve a problem? Diagrams High/Low Cohesion/Coupling Class Diagram for Factory Design Pattern Nothing 17


Download ppt "Week 5, Day 2: Decorator Decorators Muddiest Point Tomorrow: Quiz on lab reading: https://faculty- web.msoe.edu/hasker/se2811/labs/5/ SE-2811 Slide design:"

Similar presentations


Ads by Google