SE450: Review: Pattern Summary: Controlling the number of instances [20/25] Previous pageContentsNext page

Static Class: A set of global variables and functions.

Singleton: A polymorphic version of a static class. A set of global variables and functions, allowing for dynamic dispatch: actual functions not fixed at compile time.

Typesafe Enumeration: An immutable data class whose number of instances is determined at compile-time. The instances are globally accessible.

Flyweight: Ensure that at most once instance of an immutable data class for each value of the attributes. Similar to typesafe enumeration, but the number of possible instances may be large and there are no global references. Must keep references to all instances that have been created. Not on final exam.

Previous pageContentsNext page