Effective Java by Joshua Bloch:
Creating and Destroying Objects
Item 1: Consider static factory methods instead of constructors
This method translates a boolean primitive value into a Boolean object reference:
public static Boolean valueOf(boolean b) {
return b ? Boolean.TRUE : Boolean.FALSE;
}
Note that a static factory method is not the same as the Factory Method pattern from Design Patterns [Gamma95, p. 107]. The static factory method described in this item has no direct equivalent in Design Patterns.
Which difference b/w the static factory method & Factory Method pattern is the author talking about?
BalusC mentions in this thread, a link under Factory Method, java.util.Calendar#getInstance() which is a static factory method suggesting thereby that the static factory method falls under Factory Method Pattern. I think you must have got my point.
Aucun commentaire:
Enregistrer un commentaire