Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

In most of the projects at work it will eventually show up a package, a class (or multiple packages and classes) named "Utils", where every kind of function is dumped into.

It becomes excruciating harder and harder to navigate the project without a properly named structure. I have tried to ask to stop using "Utils".

When I find it if and the change to the codebase is small I normally refractor it and remove them, but they always end on showing up cluttering the code.

So do you know any strategy to make them stop doing this? Or am I just being a nagger?

share|improve this question
add comment

migrated from codereview.stackexchange.com Apr 4 '13 at 9:47

This question came from our site for peer programmer code reviews.

1 Answer

Clean code is a valid concern. I like the Guava convention of using the plural form of a type, for example, Strings, Maps, and MoreExecutors. The main problem is that someone needs one or two methods that are related but feels a class needs more than that to warrant a separate class. This is the problematic assumption, and only a culture of frequent code reviews or quick hallway-design will catch it early.

One thing that can help also helps get others to use the utility method: demonstrate it to a few others when it's convenient. It may be enough to mention during a stand-up meeting, "Hey, I created a handy utility class for trimming and standardizing our usage of strings the other day. It's called Strings and is located in package com.example.type."

I will say that I'm less concerned with a package named util as long as there is just one. This is a catch all that should contain other packages that are application agnostic, i.e., a library. Some people call this package lib or tools, but I frown on plural package names (otherwise every package would end up plural).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.