Hacker News new | ask | show | jobs
by ziml77 1275 days ago
I did something like step #2 in C# some years ago. Pulled data from the database based on the calling function’s name.

Clean Code was mental poison for me and certainly led to a bunch of overly abstracted or overly-DRY code.

1 comments

I feel like every coder has to overdo it at least once to truly grok why it is a balancing act. And I think that oftentimes leads to the discovery that every best practice is a balancing act.
A good rule is two maybe even three duplications is ok. After that, probably tome to refactor at least a little. Often this rule of thumb saves some efforts.
W.E.T. then D.R.Y.

(Write Everything Twice)

The rule should not be primarily based on a number of duplications but if we know that all the duplicated parts need to be changed when one is changed.
You're probably right on that. I now weigh my options to try to find a middle ground between impossible to change because it wasn't designed for change and impossible to change because it was designed for too many future use cases that will never happen.
IME, extensible code comes from thinking of possible extensions and then not getting in their way, which usually just means keeping it simple. Easy to say but hard to do.