DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Jonathan Hall
Jonathan Hall

Posted on • Originally published at jhall.io on

Help wanted naming this code

Show of hands.

How many of you have a library, class, or directory in your current project called helpers or utils?

Bonus points if you have both!

Actually, bonus points if you have neither.

I don’t like this naming pattern, for a few reasons:

  1. The name tells me nothing. Literally all code exists to help (otherwise it wouldn’t exist). And all code provides utility (otherwise it wouldn’t exist). So from a naming standpoint, we may as well call such a unit of code code. Or stuff or whatever or… well, I’m sure you get the idea.

  2. β€œCatch all” names like this tend to… catch all. That is, they tend to gather all sorts of random, unrelated things over time. This makes it difficult to find what you’re looking for, which leads to the next problem…

  3. These names promote code duplication. When you can’t find a function that does your neat little thing, you create a new one in a local helpers class, without realizing that it does, indeed, already exist, in some other helpers class. Now you have the same, or nearly the same, functionality in two (or more) places…

  4. It’s just kinda lazy. The same as naming a variable x or a function do(). I’m sure you can do better. What is the variable/function/class doing? Name it accordingly!


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

Top comments (0)

🌚 Life is too short to browse without dark mode