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.
Top comments (0)