more interfaces, dynamic binding, and polymorphism kirk scott
TRANSCRIPT
![Page 1: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/1.jpg)
More Interfaces, Dynamic Binding, and Polymorphism
Kirk Scott
![Page 2: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/2.jpg)
![Page 3: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/3.jpg)
![Page 4: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/4.jpg)
![Page 5: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/5.jpg)
![Page 6: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/6.jpg)
![Page 7: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/7.jpg)
• 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
![Page 8: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/8.jpg)
• 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
![Page 9: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/9.jpg)
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
![Page 10: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/10.jpg)
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
![Page 11: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/11.jpg)
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
![Page 12: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/12.jpg)
• 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
![Page 13: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/13.jpg)
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.
![Page 14: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/14.jpg)
• 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
![Page 15: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/15.jpg)
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…)
![Page 16: More Interfaces, Dynamic Binding, and Polymorphism Kirk Scott](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56649d145503460f949e8272/html5/thumbnails/16.jpg)
The End