From Design Patterns (Gamma et al) Presented by David Kemp Melbourne Patterns Group
Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype. Design Patterns, Gamma et al, Chapter 4.
Creational Patterns
Abstract Factory
Builder
Factory Method
Prototype
Singleton
Image from Flickr by Bob Henry Photography (http://flickr.com/photos/bobasonic/170043435/) Some rights reserved (http://creativecommons.org/licenses/by-nc-sa/2.0/deed.en)
Alternative to Factory Method and Abstract Factory.
Can be used to implement Abstract Factory.
To avoid building a class hierarchy of factories.
Can be used when loading classes dynamically
Often can use class objects instead.
Image from Flickr by Slowburn / Andreas Schaefer ( http://flickr.com/photos/slowburn/70150248/ ) Some rights reserved (http://creativecommons.org/licenses/by-nc-sa/2.0/deed.en)
Add/Remove prototypes at runtime.
Specify new prototypes by varying data.
Specify new prototypes by varying structure.
Less classes (less sub-classing!)
Dynamic class loading.
Discussion
Factory Method: delegate to subclasses.
AbstractFactory, Builder, and Prototype: delegate to another class.
0 comments
Post a comment