7
décembre
2011
décembre
2011
Annotation // Info
Consider static factory methods instead of constructors


On notera que Guava reprend un grand nombre de concepts évoqués dans « Effective Java » de Joshua Bloch. C’est notamment le cas des static factories auxquelles le livre consacre son premier chapitre « Consider static factory methods instead of constructors ».
Voici quelques avantages des static factories, évoqués par Joshua Bloch :
- « unlike constructors, they have names. »
- « unlike constructors, they are not required to create a new object each time they’re invoked. »
- « unlike constructors, they can return an object of any subtype of their return type. »
- « they reduce the verbosity of creating parameterized type instances. »
Retrouvez le livre « Effective Java » par Joshua Bloch sur Amazon : http://www.amazon.fr/Effective-Java-Joshua-Bloch/dp/0321356683/ref=sr_1_1?ie=UTF8&qid=1323264999&sr=8-1
Commentaires récents
- Le Stop watch de Guava dans
- Le Stop watch de Guava dans
- Le Stop watch de Guava dans