DEV Community

Seonyoung Chloe (she/they)
Seonyoung Chloe (she/they)

Posted on

45: Figure out the reasons

Don’t just solve problems, figure out what’s really going on

Too many people who write CSS and JavaScript tinker until they find something that works, and then they just move on. I know this happens because I see it all the time during code reviews.

I’ll frequently ask someone: “Why did you add float: left here?” or “is this overflow: hidden really necessary?”, and they’ll respond: “I don’t know, but if I remove it, it doesn’t work”.

The same is true of JavaScript. I’ll see a setTimeout being used to prevent a race-condition, or someone stopping event propagation with no regard for how it will affect other event handlers on the page.

I get that there are times when you need something that works, and you need it now. But if you never take the time to understand the root of your problem, you’ll find yourself in the same situation over and over again.

Taking the time to figure out why your hack works may seem costly now, but I promise it’ll save you time in the future. Having a fuller understanding of the systems you’re working within will mean less guess-and-check work going forward.

How to Become a Great Front-End Engineer

Top comments (0)