TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Extendable Builders in Java

2 点作者 czDev大约 13 年前

1 comment

lukesandberg大约 13 年前
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.