Extendable Builders in Java
akudlick.wordpress.com
Extendable Builders in Java
1–2 of 2 posts
Re: Extendable Builders in Java
#2This is the curiously recurring template pattern http://en.m.wikipedia.org/wiki/Curiously_recurring_template_.... And I'm am generally against it because it makes the type parameters noisy and confusing. A better approach IMHO is to use return type covariance in the subclass to specialize the types. Basically you override the super class methods but declare them to return the subclass type (but the implementations just call the super class implementation). It can be a little more work if there are a lot of super class methods but it creates a much more readable class.