Avoid Hasty Abstractions (AHA)
Wait until the commonalities scream at you for abstraction so you can be in the right frame of mind to provide that abstraction. Over-abstraction obscures how a system works together.
Examples
- You notice some repeated code in your component, but instead of refactoring right away, you wait until the code appears in a few more places. This way, when you create an abstraction, it’s well-informed by actual usage patterns and reduces the risk of creating unnecessary complexity.
- You need a reusable function to format currency, and there’s a use case to handle different international currencies. Instead of immediately expanding the abstraction to support that, you duplicate the abstraction with one that only supports this new use case. When you’re finished you compare the two abstractions and see whether a single abstraction is appropriate or if they should remain separate.
Share this principle