Album Cover

Design Patterns Vol. 1 Java

Close Preview
The 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.
Creation Method Sequence Diagram
In this variation, UserProfile is both Producer and Product. It has a Creation Method that is static.
Example Creation Method Players
In this example, LoanFactory has several
non-static Creation Methods.
Non-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:
Example Creation Method Players
| Tweet...
Page rating: | Rate this Page