Back to Blog Do not Optimize Prematurely

Do not Optimize Prematurely

97 Things Not To Do

Once again, you would think that the software development community has moved past this point, but I still get many teammates who want to “save memory” using HashMaps instead of POJOs. I am not too sure how efficient HashMaps are compared to POJOs, but I am sure of how they can become a maintenance nightmare if we start using maps wherever we could use POJO.

In hindsight, it now seems foolish, but I have been guilty of committing crimes like sprinkling static variables, singletons, and data structures like maps instead of more compiler-friendly data structures. All this is because either I had some misconception about how performance optimization works or an obscure scenario in my mind like “what will happen when 2,13,00093 users access my piece of code in parallel.”

Between a speculative performance issue that you may or may not encounter and the use of clean code, clean code should always win. If your code is clean, it will be easy to find it and fix it when a performance issue arises.

Consider Sharing!