What are the differences between Helper and Utility classes?

There are many naming styles to use. I would suggest Utils just because its more common.

A Utility class is understood to only have static methods and be stateless. You would not create an instance of such a class.

A Helper can be a utility class or it can be stateful or require an instance be created. I would avoid this if possible.

If you can make the name more specific. e.g. if it has sorting methods, make it XSorter

For arrays you can find helper classes like

Array
Arrays
ArrayUtil
ArrayUtils
ArrayHelper

BTW a short hand for a utility class is an enum with no instances

enum XUtils {;
    static methods here
}

If you need to implement an interface, I would use a stateless Singleton.

enum XHelper implements RequiredInterface {
   INSTANCE;
   // no instance fields.
}

In general? It's entirely arbitrary. There are no rules for this.


A utility is a "leaf node" class of general use. That is, it doesn't have any dependencies into your project and can be ported from project to project without breaking or becoming useless. Examples: Vector3, RandomNumberGenerator, StringMatcher, etc...

A "helper" seems to be any class whose design is to aid another class. These may or may not depend on your project. If you're creating a GameNetworkClient class, you could say the GameNetworkConnection class is a 'helper', because it "helps" the GameNetworkClient.

The way developers refer to tools reflects common usage of these words. If you can recall hearing tools described as "helpful" vs "useful", a helpful tool tends to have some context (cheese grater helps to grate cheese, corn stripper helps to strip corn, speed loader helps to reload a firearm). A "utility" is expected to work in a variety of contexts (WD-40, duct tape, army-knives, glue, flashlight, etc...).