As Harry Roberts says, “DRY is often misinterpreted as the necessity to never repeat the exact same thing twice. This is impractical and usually counterproductive, and can lead to forced abstractions, over-thought and over-engineered code.”
We kicked off a new session of the Vanilla JS Academy last week, so I decided to rethink my approach. I opted for two separate functions this time: one for counting words, and one for counting characters.
This is so much better!
Two separate functions, each with its own job. The code is now easier to read, test, and maintain thanks to my newfound separation of concerns.
Keep it simple, stupid! 🥴
If you have questions, feedback, or any other suggestions, please do email me. I'd love to hear from you!