Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!


Forgot your password?
DEAL: For $25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 internet speed test! ×

Submission + - The Blind Builder: Alternative to Bloch Builder, for highly-extendable classes (stackexchange.com)

aliteralmind writes: I have been greatly influenced by Joshua Bloch's Effective Java (2nd edition), probably more so than with any programming book I've read. In particular, his Builder Pattern (item 2) has had the greatest effect on me. I have gotten farther in the past couple of months since discovering this book, than in my past decade of programming. Despite this, I am still finding myself hitting the same wall: Extending classes with self-returning method-chains is at best discouraging, and at worst a nightmare--especially when generics come into play, and especially with self-referential generics, such as Comparable<T extends Comparable<T>>. As a result, I have created what I call "The Blind Builder", which is a replacement for the Bloch Builder, for a very specialized situation: for use in classes that are highly-reusable, and intended for extending and sub-extending many times over. Not to say in any way that this pattern is "better", just that in this particular situation it does provide some advantages. The biggest is how it decouples the to-be-built class from its builder, allowing it to be extended without having to extend its builder. Another benefit is that, aside from a single character, The Blind Builder is used in exactly the same way as the Bloch Builder. This pattern is thoroughly documented, and is presented in a question-and-answer format.

Slashdot Top Deals

Philosophy: A route of many roads leading from nowhere to nothing. -- Ambrose Bierce