SE450: Review: Pattern Summary: Creating instances [21/25] Previous pageContentsNext page

Static Factory: a static class whose purpose is to generate instances of an interface (or interfaces). The interface and factory are public, but the implementing classes are not.

Abstract Factory: A polymorphic version of a static factory. Abstract factories are usually singletons. Not on final exam.

Builder: A mutable object used to build an immutable object. Add pieces to the builder gradually, then convert to its immutable representation (eg, StringBuilder).

Prototype (clone): A method that generates an object based on the actual type of the receiver. The returned object is a copy of the receiver.

Factory Method: A method that generates an object based on the actual type of the receiver. Factory methods are used to tie together related interfaces (eg, Collection and Iterator). Once I have a concrete instance of the primary interface (Collection), I can use it to generate concrete instances of the subsidiary interface (Iterator). Not on final exam.

Previous pageContentsNext page