Download presentation
Presentation is loading. Please wait.
Published byOswald King Modified over 9 years ago
1
More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott
7
This is an introductory unit. These are the units/chapters belonging to this section of the course: Unit 20, Factory Method, book chapter 16 Unit 21, Abstract Factory, book chapter 17 Unit 22, Command, book chapter 24 Unit 23, Bridge, book chapter 6
8
What will be given next is an extremely brief overview of these topics. Although the patterns are different from each other, they continue the theme that runs throughout design patterns They illustrate the use of interfaces, polymorphism, and dynamic binding to accomplish various programming goals
9
Factory Method Book definition: The intent of the Factory Method is to let a class developer define the interface for creating an object while retaining control of which class to instantiate. Comment mode on: We’ve seen the use of an interface already several times This takes it into the realm of construction
10
Abstract Factory Book definition: The intent of the Abstract Factory, or Kit, is to allow creation of families of related or dependent objects. Comment mode on: It is not an accident that this is treated along with Factory Method It is an extension of that idea
11
Command Book definition: The intent of the Command pattern is to encapsulate a request in an object. Comment mode on: This pattern is not necessarily closely related to the factory patterns However, the “other example” for the command pattern follows directly from the “other example” for the factory patterns
12
Informally, this pattern allows you to “pass a method” You do this by creating a class containing the desired method, constructing an instance of the class, and passing that object as a parameter In the receiving code it is then possible to call the desired method on the object
13
Bridge Book definition: The intent of the Bridge pattern is to decouple an abstraction from the implementation of its abstract operations, so that the abstraction and its implementation can vary independently.
14
Comment mode on: I don’t find this statement very helpful The bridge is a very interesting and useful pattern In preview summary, to my mind it is a special kind of adapter It probably won’t be clear until an example is shown
15
In Summary and Mnemonic Devices: Factory Method: Constructing and returning various kinds of objects, typed to a common interface (mushroom management: keep the client code in the dark) Abstract Factory: Constructing and returning families of objects (family values) Command: Wrapping a method so that it can be passed around (in brief, “passing a method”) Bridge: A lovely kind of adapter (bridges are beautiful…)
16
The End
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.