SE450: Creational Patterns: Static Factory [6/12] ![]() ![]() ![]() |
Normally, how do you create an instance of a class?
However, you can write your own method to instantiate a
class. This is not one of the GoF patterns, but is
documented in Joshua Bloch's Effective Java.
Benefits: Static Factory methods...
Disadvantages:
Convention:
valueOf
Returns an instance that has,
loosely speaking, the same value as its parameters.
Basically, it is a type conversion operator.
getInstance
Return an instance that is
described by its parameters but cannot be said to have
the same value. Used with Singletons (later). Used in
provider frameworks.