Friday, October 24, 2008

Utils classes and NOJOs

A style of class that is a frequent complement to NOJOs (introduced in my previous article) are classes with only static methods. They might be called SomethingUtil or SomethingHelper.

People will often know what you mean if you say "a Utils" class, so I won't propose anything different here. I had wanted to propose a catchier name - SOJOs (Static Only Java Object) but the acronym (with a completely different meaning) is already taken by the SOJO project. In a comment on my NOJO article, John Q Public said he uses the term "function buckets" and I'm sure he's talking about the same thing.

Why do people write Utils classes?

If you have NOJOs then your methods have got to go somewhere. People who prefer the NOJO style often like to create static methods on Utils classes for those methods.

Are Utils classes a Good Thing?

Again, left as an exercise for the reader. An article from my old blog might help to hint about my views (although it is not specifically about this subject) without me having to stay up all night writing more. It seems like people aren't shy about expressing their opinions in comments - some of which I completely agree with, so I'll leave it as an exercise for comment writers as well as the reader (cheeky, I know).

In defence of my previous article

I didn't make any judgements in my previous article - mostly through lack of time but also because I want the term NOJO to be understood without being confused with whether it's any good or not. I am merely making an observation and suggesting a name for a thing I see frequently, that is poorly served by current names. I found it interesting how many people suggested that there was already a term for NOJO but none of their suggestions were entirely accurate.

Copyright © 2008 Ivan Moore

2 comments:

Ivan Moore said...

Ah. When I wrote "none of their suggestions were entirely accurate" that was before I read Philip Schwarz's comment. Indeed, "DataClass" is accurate (just not very catchy). I'd completely forgotten about that term.

Philip Schwarz said...

Ivan, you said: I'd completely forgotten about that term.

Not surprising since as you said it is not very catchy. NOJO is eminently catchy. And now SOJO (shame it is already taken)...you are on a roll, this is good, don't stop now.

For what it is worth: I find your post did make it plain, that your intention was not to judge (due to e.g. lack of time), to merely make an observation and suggest a useful name.