2 ms·
Your example of three times, is another common refactoring heuristic called the "rule of three" (I think Don Roberts coined the term). It's not incompatible wit
by kasey_junk 13y ago
Your example of three times, is another common refactoring heuristic called the "rule of three" (I think Don Roberts coined the term). It's not incompatible with YAGNI, rather by the time you've got three examples you have proof that you do need something.
Arguing about YAGNI is sort of hard because developers fall into 2 camps, those that have spent more time in systems that were too abstract, and those that have spent more time in systems that were not adaptable enough. Your feelings on YAGNI are going to be very biased based on this.
I fall into the very pro YAGNI camp, because I think it is very, very hard to "design" for an unknown future. You can guess, but that's all it is, a guess. Why not wait until you can know what the abstraction should be?
Finally, introducing a class hierarchy for code reuse, is almost always a bad idea, YAGNI or not.
- angersock 13y ago"Finally, introducing a class hierarchy for code reuse, is almost always a bad idea, YAGNI or not." Agreed, which is why component architectures are awesome. :) That said, in certain languages and with certain system philosophies, it's the Right Thing to do--especially when you know that the feature will be needed. I don't promote that we prematurely abstract things out of ignorance, but out of convenience.