TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Extendable Builders in Java

2 pointsby czDevabout 13 years ago

1 comment

lukesandbergabout 13 years ago
This is the curiously recurring template pattern <a href="http://en.m.wikipedia.org/wiki/Curiously_recurring_template_pattern" rel="nofollow">http://en.m.wikipedia.org/wiki/Curiously_recurring_template_...</a>. 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.