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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

The Rule of Three

172 点作者 mschalle将近 12 年前

10 条评论

Cogito将近 12 年前
At first I thought this might have been a repost of some refactoring advice I heard of long ago. A quick google finds a reference on wikipedia [0]. Essentially it goes like this:<p><pre><code> The first time you implement something, just do it. The second time you implement the same thing, copy it. The third time, refactor. </code></pre> The OP seems like an interesting variation on the same theme.<p>[0] <a href="http://en.wikipedia.org/wiki/Rule_of_three_(computer_programming)" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Rule_of_three_(computer_program...</a>
评论 #6068766 未加载
评论 #6072053 未加载
评论 #6071907 未加载
socialist_coder将近 12 年前
This is even more true in game development. So many developers making games want to try and make reusable components across games but almost every game is &quot;special&quot; and will require some kind of tweaking to make the component truly reusable.<p>And then, you&#x27;ve just bloated your component to support different use cases and made it slower, harder to understand, and potentially buggy; all in the name of &quot;reusability&quot;. And it takes you 3 times longer to implement this shared component vs just making copy &amp; paste single use solution.<p>Game development is truly an art. Knowing when to just &quot;get it done&quot; vs &quot;write a more reusable component&quot; is something that I&#x27;ve seen very few people in game development be able to get right.
vlasta2将近 12 年前
I have a problem with the word reusable. A reusable software should be a component in a larger solution. Not a complete solution itself.<p>If I accept that Stack Overflow or Discourse are reusable, because you can run them on different urls with different graphics, topic, moderators and users, then every application, for example Photoshop, is reusable in the same way, because multiple people use it to perform multiple tasks with images.<p>What you do with Discourse is good engineering, but there is nothing special about it. Every serious CMS, like WordPress or Drupal must inevitably be usable more than once.
评论 #6069930 未加载
评论 #6070378 未加载
one-man-bucket将近 12 年前
<p><pre><code> Less than three? Control-C, Control-V. Three or more? Refactor!</code></pre>
lysa将近 12 年前
Wow what a horrible way to advertise your products. Disguise your advertisements into some substanceless article seemingly useful.
评论 #6069521 未加载
评论 #6069119 未加载
评论 #6070099 未加载
gioele将近 12 年前
I remember that a Xorg development guideline explicitly required the same code to be used by at least two different subsystems (using hard coded if-based paths or copy&#x2F;pasted) before it could be generalized into a parametric reusable function.
mafro将近 12 年前
Nice post. I was more interested in the fact that Discourse was being real-world tested&#x2F;developed with three clients than this trite &quot;rule of three&quot; business though.
nileshtrivedi将近 12 年前
I have had a similar thought. The multiple of 3 seems to be a nice heuristic to track and tame complexity in many fields. Nature of any problem undergoes fundamental changes when the problem size is tripled and our solutions should be reviewed accordingly.<p>Here is what I mean. Say your startup has only one employee. You come up with certain processes to make it productive. However, when the team size goes to 3, 9, 27, it would be a good idea to review those processes and rules. Those seem like appropriate milestones to me for future planning. Not too short, nor too long.<p>Another example: Let&#x27;s say I want to understand a topic like, say, Relativity. I think an effective approach would be to first read a one paragraph summary which barely describes the big picture of it. Once I&#x27;ve done that, I look for an article 3-times as long (say, a page). Next would be an essay which is about 3 pages. 9 pages, 27 pages and so on.<p>By not taking a big jump, (say a multiple of 10 or more), I make sure that I have a good foundation based on experience to be able to understand the next stage of complexity. And a jump less than a multiple of 3 would tend to be not the most productive.
quchen将近 12 年前
What <i>hyphenated site</i> is he referring to?
评论 #6068920 未加载
评论 #6072928 未加载
groundCode将近 12 年前
I like the sentiment. Battle testing your generalised solution is always a good idea. It&#x27;s also a good idea to know when you <i>don&#x27;t</i> need a generalised solution.