by qwery · 3y ago · 0 comments
YAGNI is a somewhat similar advice, and a good one -- at least for my overengineering inclined brain. But if for every single decision you invoke YAGNI, because overengineering is bad, you can also end up with bad code. Even in that case though, the standard for what is "bad code" depends on context (goals, deadlines, etc.). Even "objectively" bad code might not have a significant impact on the project, again depending on context.
Article is from 2010-12-24, posted a bunch of times. Earliest: https://news.ycombinator.com/item?id=2037576
If one can also be humble, and take other opinions into consideration, then that's someone I enjoy working with. I strive to be this person towards others.
And I think all the advice has to be taken through that lens. Of course someone who is in the midst of their programming journey is going to say, "No, I want to do the advanced thing now. I'm advanced."
But if "being a programmer" is a disease one wishes to rid themselves of, then advanced programming is merely advanced disease. And that point is roughly when you start to be able to make the right call when asserting YAGNI, because then you can identify with more clarity when the code deserves to be heavy, load-bearing stuff, and when it needs to be more like "code as an asset" - simple loops and branches that help configure the heavy machinery.
Examples?
YAGNI is a very abused term. I tend to find when people talk about exceptions to it theyre talking about things which don't actually fall under the header of preemptive features or preemptive refactoring.
You went through YAGNI. DRY is the same thing. It's often very good advice. But there are certainly limits to DRY... calculating the area of a rectangle from its width and height in two different repositories in the same company probably wouldn't justify creating a library to be shared between them. There's a line somewhere in the middle. Being skilled at understanding what side of that line a given case should fall on is something we build with experience.
I think YAGNI and DRY are at their best as advice when they come packaged together, putting them in tension in order to prompt us to find the right balance and not to blindly follow either one. Taken together, they give us a framework for thinking about one set of tradeoffs. I believe the core of software engineering (and many other pursuits) is identifying the most important tradeoffs and finding a good balance among them. Blindly following advice can get in the way of that.