Effective Java Reload

Joshua Bloch wrote the seminal book Effective Java. That is one book that needs to be in your Java bookshelf. Joshua does not have a new edition of Effective Java but in this session he shows effective use of some of the new Java 1.5 features, such as Generics. Here are some blurbs from the Effective Java Reloaded session.

Static factories have advantages over constructors. You should strive to minimize mutability. Use the Builder pattern to emulate named parameters. Optional parameters will require a setter method in the builder class. Have build method in the Builder class that will actually create the instance of the class you are building. Avoid raw object types, use generics. In generics, prefer wildcards to type parameters. Wildcards are good in you API as parameters but it is a bad design to return a generic with a wilcard. According to Joshua, returning a wildcard generic smells like bad code. Generics and arrays don’t mix, prefer generics. Here is a mind expanding pattern: THC, that is Typesafe Heterogeneous Container. And finally, final is the new private. Joshua stated, “get used to typing private final.”

This was a great session lead by a great developer.

Technorati Tags: , , , ,