FactoryPattern: Difference between revisions

From Wiki RB4
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Factory Pattern=
=Factory Pattern=


Instead of calling <code>new X()</code> in java code you use <code>XFactory.get()</code>, so you have a decoupling of the actual type, which is good for:
Instead of calling <code>new X()</code> in java code you use <code>XFactory.get()</code>
 
==Advantages==
You have a decoupling of the actual type, which is good for:
* testing
* testing
* different environments
* different environments
==Disadvantages==
* lots of coding for factory classes
* compile time depency leads to high build times
==Alternatives==
* explicit injection by parameter of the ctor

Latest revision as of 13:21, 2 February 2010

Factory Pattern[edit]

Instead of calling new X() in java code you use XFactory.get()

Advantages[edit]

You have a decoupling of the actual type, which is good for:

  • testing
  • different environments

Disadvantages[edit]

  • lots of coding for factory classes
  • compile time depency leads to high build times

Alternatives[edit]

  • explicit injection by parameter of the ctor