ITEC 370 Lecture 12 Design
Review Questions? Design patterns –How useful are they? –Command pattern What is it? What can it do for you?
Design Objectives Design patterns –A few good ones
Design Review Design patterns Command pattern –Definition –Example
Design Adapter Square peg, round hole problem Use aggregation or inheritance Pass-through for a system Example
Design Bridge Two software parts, and a desire to not strongly couple them Class A / Class B A and B only interact with each other using class C Only C has to be changed if A/B changes Examples
Design Factory Used to create instances of a class –Not just a constructor Many variants –Static interfaces –Separate class (similar to a bridge) Goal –Have something that takes information and returns a class that can be used –DB entry
Design Flyweight Bookmark or easily recognizable piece of information Goal: create one and use it everywhere –NULL –Leaves on a tree Memory saver
Design Facade Used to hide the gory details from the end user Abstraction layer Many functions combined into one –Depends on what the API requires Lego Robot example
Design Observer Notification pattern One source of events Many classes interested in said events When one happens, they are informed from it How would you design this functionality?
Design Memento Saves information so it can be restored later Create a save function Create a recall function Self contained or use an archive class Undo
Design Strategy Task –Multiple algorithms to accomplish this task –Pick one at run-time –How/Why? JVM
Design Chain of responsibilit y Mimic chain of command One class multiple choices Based on the “ranking” of an action, a particular choice Example –Threat level of an warning/error
Design Review Design patterns