DEV Community

Cover image for Escaping from being stuck in the optimization trap
TyIsI
TyIsI

Posted on

Escaping from being stuck in the optimization trap

I've been meaning to write a post on here for a while, but we all know how it goes. Distractions, busy, other projects, not enough time.

But I had an interesting epiphany the other day. One that I thought was worthwhile sharing. Because everyone has their own experiences and ways to get unstuck.

As I was stuck on refactoring something and reflecting the best approach, I was thinking about it as "what is the smartest way to solve this? and more so "what exactly am I trying to solve and what is the smartest way to do this?".

And that's when it struck me.

Sometimes the smartest way to do a thing is to not do it in the smartest way (possible).

We can always optimize the optimizations and abstract them further. But is there an actual tradeoff for doing this? Or are we simply trying to optimize it for the sake of optimizing? Are we abstracting for the right reasons or just because it's the way that we tend to do things?

So for future cases, if I feel I'm stuck on a problem, I'm going to try to remember to ask myself this:

Am I trying to optimize the optimization?
(And can I settle for good/close enough?)

Because sometimes two pieces of code is better than (a more complex unified) one.

But I would certainly be curious to hear opinions from the community.

Image Source

Top comments (0)