Creation Method: Meet Your Maker
Creation Method Players
Creation Method brings together three key players:
- Consumer — (A.K.A. Client or Customer) an object that needs some product and invokes a Creation Method to get it.
- Producer — an object that can produce the needed product. The Producer will have either a static or non-static Creation Method on it.
- Product — the object to be produced.
In this variation, a Consumer asks a Producer for a Product.
In this variation,
UserProfile
is both Producer and Product.
It has a Creation Method that is static.
In this example,
non-static Creation Methods.
LoanFactory
has severalnon-static Creation Methods.
LoanFactory
's sole purpose is to produce Loan
instances. Notice that the Loan
constructor is protected.
In this example, the Products are a subclass of the Producer
and again, the Creation Methods are static:
and again, the Creation Methods are static:
(Reading...)
Formatting Hints:
To format... | use this markup: |
---|---|
source code | {source:lang=java|lineNumbers=false}...{source} (Supported languages: java, cpp, csharp, c, python.) |
bold text | __some text__ |
italicized text | ~~some text~~ |
underlined text | @@some text@@ |
a method or class name | ``myMethod(...)`` |