Skip to main content Accessibility Feedback

AHA programming, a nice balance between DRY and WET

On Tuesday, I wrote about DRY programing, and how it’s actually OK to repeat yourself.

Someone pointed me to this article by Kent C. Dodds from two years ago on AHA programing as a nice follow-up read.

AHA (pronounced “Aha!” like you just made a discovery) is an acronym I got from Cher Scarlett which stands for “Avoid Hasty Abstractions.”

The way I think of this principle is beautifully described by Sandi Metz who wrote: “prefer duplication over the wrong abstraction.”

This is such a solid golden nugget of wisdom that I want you to read it again, then read Sandi’s blog post on the subject: The Wrong Abstraction. It’s fantastic.

For me, these two sentences really sum up years of evolving thinking and experience for me:

I think the key is that we don’t know what the future of code will be. We could spend weeks optimizing code for performance, or coming up with the best API for our new abstraction, only to find out the next day that we made incorrect assumptions and the API needs a complete rework or the feature the code was written for is no longer needed.

Go read Kent’s entire article, and the articles he links to. It’s all really good stuff!