DEV Community

Cover image for Junk drawer
Jonathan Hall
Jonathan Hall

Posted on • Originally published at jhall.io on

Junk drawer

Every house has a junk drawer.

It’s where we put random small or unique items that don’t really belong anywhere else.

Many code bases have junk drawers, too. They’re usually classes or packages with names like “helpers”, “utils” or “common”.

Does the fact that your house has a junk drawer justify a code junk drawers? I don’t think so.

If physical drawers were free, and took up no space, we probably wouldn’t have junk drawers in our homes, either.

If it was economical and space-efficient to create a drawer just for rubber bands, why not? And why not a drawer just for the stapler? And a separate drawer just for the battery door that fell off of a random toy your kid got for Christmas last year.

Obviously, that’s not practical in the physical world.

But in code, those “drawers” are free. So there’s never a good reason to start throwing your code “junk” into a junk package. Give each package/class its own meaningful name. Even if it only contains a 2-line helper function. Classes are free. Use them!


If you enjoyed this message, subscribe to The Daily Commit to get future messages to your inbox.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay