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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

When DRY becomes an anti-pattern: Code in Code

12 点作者 c23gooey超过 3 年前

2 条评论

karmakaze超过 3 年前
The anti-pattern here is applying DRY to <i>text</i> rather than intents. The identical text may appear in a different source file with a different intent, say a tax calculation for a region. It may very well be that two regions have the same formula, but it&#x27;s obvious that you shouldn&#x27;t DRY it.<p>The example used in the post had no real-world intent. The intent was to blindly apply DRY which doesn&#x27;t count as one.
Matthias1超过 3 年前
I&#x27;d argue the example given in the article is bad not because it doesn&#x27;t repeat itself, but because it only concats strings. Using more advanced language features, or perhaps a ORM, I think you could easily come up with a solution that doesn&#x27;t involve repeating parts of SQL queries but is still readable.
评论 #28823206 未加载