Presentation is loading. Please wait.

Presentation is loading. Please wait.

Slide design: Dr. Mark L. Hornick

Similar presentations


Presentation on theme: "Slide design: Dr. Mark L. Hornick"— Presentation transcript:

1 Slide design: Dr. Mark L. Hornick
SE-2811 5/23/2018 Week 6, Day 2: Decorator Review Muddiest Points for Quarter Decorators Muddiest Point Tomorrow: Direct Supply tour with Kent Newbury Demos of (hopefully working) labs Lab due in the evening No new lab this week. SE-2811 Slide design: Dr. Mark L. Hornick Content: Dr. Hornick Errors: Dr. Yoder Dr. Yoder

2 SE-2811 5/23/2018 Muddiest Point See Muddiest Point Table online: slides/se MuddiestPoint.xlsx (and on my machine) SE-2811 Dr. Mark L. Hornick Dr. Yoder

3 How are decorators useful?
CS-1020 5/23/2018 How are decorators useful? Decorators have the same super-type as the objects they decorate. One or more decorators can be used to wrap an object. One answer to question 1: Given that the decorator has the same super-type as the object it decorates, we can pass around a decorated object in place of the original (wrapped) object. One answer to question 2: Objects can be decorated at any time, so we can decorate objects at runtime with as many decorators as we like. Helps organize: e.g., can put all beverage objects in the same data-structure Used when initializing super-class Why is this useful? Can still get to specific & useful method When creating the object By casting back to cream (leaves open question: Is it cream?) Test using instanceof Can get more & more specific about the object with multiple decos. Don’t need all the classes for all combinations Dr. Mark L. Hornick

4 Downsides What are the disadvantages of decorators?
SE2811 5/23/2018 Downsides What are the disadvantages of decorators? See interview drama on p. 104 in the text (Head First) Large number of small classes overwhelming to new developers Problem when people rely on specific types without thinking through [TODO: Study & find example] e.g. Consider the mess if the interface does not already exist for the class Complexity of wrapping many to construct a new one SE-2811 Dr. Mark L. Hornick Dr. Josiah Yoder

5 Forced selection: Do you like Java's I/O? Yes / No
5/23/2018 Forced selection: Do you like Java's I/O? Yes / No SE-2811 Dr. Mark L. Hornick Dr. Yoder

6 Join those who agree with you in defending your position!
5/23/2018 Join those who agree with you in defending your position! I like Java's I/O decorators I don't like Java's I/O decorators SE-2811 Dr. Mark L. Hornick Dr. Yoder

7 Alternative Decorator Designs
SE-2811 5/23/2018 Alternative Decorator Designs x SE-2811 Dr. Mark L. Hornick Dr. Yoder

8 How to create a car with a sunroof and radio?
SE-2811 5/23/2018 How to create a car with a sunroof and radio? SE-2811 Dr. Mark L. Hornick Dr. Yoder

9 Decorator vs. Array of Add-ons
SE-2811 5/23/2018 Decorator vs. Array of Add-ons What is the advantage of using your pattern? SE-2811 Dr. Mark L. Hornick Dr. Yoder

10 Decorator vs. Array of Add-ons
SE-2811 5/23/2018 Decorator vs. Array of Add-ons SE-2811 Dr. Mark L. Hornick Dr. Yoder

11 Downsides What are the disadvantages of decorators?
SE2811 5/23/2018 Downsides What are the disadvantages of decorators? See interview drama on p. 104 in the text (Head First) Large number of small classes overwhelming to new developers Problem when people rely on specific types without thinking through [TODO: Study & find example] e.g. Consider the mess if the interface does not already exist for the class Complexity of wrapping many to construct a new one SE-2811 Dr. Mark L. Hornick Dr. Josiah Yoder

12 https://www.polleverywhere.com/free_text_polls/zIp2tH2IVWjXv4H SE-2811
5/23/2018 Muddiest Point SE-2811 Dr. Mark L. Hornick Dr. Yoder

13 Threading Muddiest Point [To be revisited in a future lecture]
SE-2811 5/23/2018 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 More examples of using lambdas (didn't get exposure in software dev 2) Effectively Final? "Effectively Final" SE-2811 Dr. Mark L. Hornick Dr. Yoder

14 Patterns Muddiest Point [To be revisited in a future lecture]
SE-2811 5/23/2018 Patterns Muddiest Point [To be revisited in a future lecture] 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 Dr. Yoder

15 Decorator vs Strategy SE-2811 5/23/2018 Dr. Yoder SE-2811
Dr. Mark L. Hornick Dr. Yoder


Download ppt "Slide design: Dr. Mark L. Hornick"

Similar presentations


Ads by Google