DEV Community


Posted on

Do Whatever You Want, So Will I


Moving toward the creative side may result in more shit, but neat things can grow out of it.

While writing an article explaining why spreading props to React components is a bad idea - and it is - my hairline receded, white hairs appeared in my beard, the music around me became too loud, and no one's clothes made any damned sense.

Technically, all that stuff happened slowly over many years, but I suddenly saw it as I prepared another shit talking session about all the crap code I've run into in the wild. What the hell? When did I become so fucking cranky?

Yes, if everyone did things a certain way, everything would be fine. Fine-ish. It may be stable, but without crazy ass innovation. We would have a world of very resilient, performant spreadsheets.

But I certainly didn't start writing code because of a desire to take up the cause of the clean code brigade. I couldn't have given less of a shit. I had an idea that I wanted to present and the tool to do it was code. Over time, possibly because of pursuing a career in code and not the artifacts I once used them for, I've become obsessive over the freaking tools. Like some crusty, psycho carpenter sharpening and organizing blades, forgetting about the freaking cabinets he was supposed to make.

"Listen up! If you want to make cabinets, you need to stop and learn your tools. I mean really learn them. Learn care and maintenance, learn other tools you can use to make these tools better, and go around making sure others use their tools right. If you're interested, I've written a lot about how to use these tools. I've even made tools that can make other tools. If people would just use the right freaking tools, all the cabinets would be perfect."

Meanwhile, some asshole using a chisel as hammer whacked together 16 cabinets.

Who cares? Let people suck.

Wild analogy shift in 3...2...1

When trying resuscitate a weed-infested lawn, you may be tempted to run straight to the weed killer. That will kill the weeds, but has a negative overall effect on the lawn's health. This results in a weaker lawn, which is more likely to sprout weeds.

Adding poison is a negative action.

A better reaction is to focus on nurturing the lawn. Add phosphates and shit. That will make the grass healthy, which will flourish, and not give the weeds anywhere to hang out.

Adding fertilizer is positive.

This pattern comes up a lot in life. Pessimism and overall negativity are not creative. And writing software is - hold onto your planning meeting notes - a creative process. Meetings and story points and micro-managing dickbacks may have slowly sucked the life out of it, but I started doing this because it was another art form and pretty fun.

I've stashed my cranky article for now.

Top comments (4)

maybebored profile image

Please explain why spreading props is a bad idea; is your reasoning is any different from this -

reergymerej profile image

That's a good article and I agree with a lot of it. In general, the problem with spreading props is obscurity and messiness. Child components end up accumulating a lot of stuff that is not meant for them and the origin can become obscured.

Even the React docs state...

Spread attributes can be useful but they also make it easy to pass unnecessary props to components that don’t care about them or to pass invalid HTML attributes to the DOM. We recommend using this syntax sparingly.

maybebored profile image

Agreed. It would be more precise to say passing unnecessary props to a component is a bad practice. Spreading props is merely a technique allowed by JS. This got me thinking, does React warn when a component receives an unexpected prop, and turns out there is a pluggable solution -

kravemir profile image
Miroslav Kravec

The issue isn't just in passing of unnecessary props. That's just a performance micro-optimization, which can be done later,..

Spreading props also allows to hide high amount of tight coupling, and such code looks simple on first sight, and falsely KISS. However, a new developer has to trace and inspect lots of components/layers in order to understand data/control flow of such code.