This week's book giveaway is in the Agile and Other Processes forum. We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line! See this thread for details.
In bruce eckel book, builder pattern returns a product which can be Book or Magazine or WebSite . all having a parent Media Type. This makes sense to me. So in builder class, return type points to Media (parent) rather than specific child class like Book or Magazine or WebSite when i was trying to do a sample excercise, in which one Builder that puts the words into a java.util.TreeSet, and another that produces a word count to java.util.HashMap my question: One builder returns TreeSet , another builder retruns HashMap how do I map to a common base product. I want to do something similar to Media -- Magazine, Web, Book. where Media is shown as Return type in each Builder class
Introducing a common base type only makes sense if the product needs to be processed by common code. In that case what it should look like would heavily depend on how it gets used. Otherwise, you could simply declare Object as return type or even don't declare a common query method at all.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad: