Bugs, Cruft, and Other Spooky Code-stuffs


Author profile picture

@austinAustin Pocus

Do not attempt to adjust your set. We are controlling transmission.

Gather ’round the campfire, and let me tell you a scary story, one that you might already know from the bones. But, when added to the flesh and sinew of raw detail, you might find yourself sweating, thinking of an all-too-familiar codebase…

If you’re old enough to recognize this, I have a few scarier things to tell you, later.

The bug seemed simple enough: our dashboard on app.hackernoon.com was flashing a login form, then once the login state loaded, it was flashing an empty dashboard while the drafts loaded. Simple enough…just wait for everything to load.

Right?

Dead wrong.

I entered through the main entrance, the

Home

component which rules over our dashboard, powering data fetching, etc. A “smart component”, if you will. For each section of the dashboard, there’s a component too, like

HomeDrafts

for, you guessed it, the section that displays your drafts. Of course, this component, being one of the early abstractions in our codebase, has another concern: displaying the welcome screen or the draft dashboard, based on internal loading state.

Do you smell it yet?

The kind of old cartoons, an old oldie…

One component should have one concern. That concern can involve many different moving parts — for example, our `Home` component handles data loading for a few collections in the database — but never should the two concerns interfere with one another.

Unless you’re implementing a concurrent process with Node streams, in which case you should totally cross them.

More than that, we have some concerns spread across multiple components!

It’s not quite this bad, but it does feel Hydra-like sometimes

As you make changes in

HomeDrafts

, you have to make changes in

Home

, which necessitates a change in the master

Routes

file (this was before Next.js was widespread or even usable for our needs). This has led to a beast, lurking within our system, an insatiable beast called the “Cruft Creature”

The Cruft Creature is fed by deadlines. The Cruft Creature eats developers in a rush. It devours your future, by giving you a temporary reprieve in the present.

It kills time. It kills your future.

Squidward needs to chill. Stressing me out.

There is a weapon that is said to be able to destroy the Cruft Creature…it’s a powerful set of tools: refactoring, rewriting, and throwing away obsolete code, among other tools. However, these weapons are deadly! In the wrong hands, you can destroy yourself in the process…don’t overdo it, in other words.

I’ve been beating back the Cruft Creature, in our own codebase. It has retreated into the dank depths for now. But they say it has siblings…

Siblings that feed on other codebases, other systems…

One of them…MAY EVEN BE YOURS! 😱

All gifs courtesy of Tenor.com.

Tags

The Noonification banner

Subscribe to get your daily round-up of top tech stories!

Don't forget to share

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *