Tuesday, March 10, 2015

Solving Builder Pattern Inheritance

...using a generics-based approach outlined here:

https://weblogs.java.net/node/642849

I have feeling this could also be applied to the problem of fluent interface issues having to do with forcing the caller to append properties in the order of super class to sub class -- that was addressed in this article. It also appears to solve in an elegant way the code smells associated with doing unchecked casts like return (T) this; or returning raw types. The trick to solve these issues appears to be the use of "self-referential" type parameters.