Naming Conventions for Utility Classes
You'll learn how to choose clear, consistent names for your utility classes that communicate their purpose at a glance.
When you create a utility class, the name matters—it's the first clue about what's inside. There are several common naming patterns you'll see throughout Java codebases.
Generic Suffixes: Utils, Utilities, Helper
Many developers append suffixes like Utils, Utilities, or Helper to utility class names:
public final class StringUtils {
private StringUtils() {}
public static boolean isEmpty(String str) {
return str == null || str.length() == 0;
}
}
These suffixes clearly signal "this is a collection of static methods," but they're generic. StringUtils tells you it works with strings, but not what kind of operations it performs.
Descriptive Domain Names
A better approach is often to use descriptive, domain-specific names that reveal the class's exact purpose:
public final class PriceCalculator {
private PriceCalculator() {}
public static double applyDiscount(double price, double percent) {
return price * (1.0 - percent / 100.0);
}
}
PriceCalculator is more meaningful than PriceUtils—it tells you what the class does, not just that it's a utility.
When to Use Each
Use generic suffixes (Utils, Helper) when you have a broad collection of loosely related operations. Use descriptive domain names when the class has a focused, cohesive purpose. For example, Math (from Java's standard library) doesn't need a suffix—its purpose is crystal clear.
Avoid vague names like CommonUtils or Misc—these become dumping grounds for unrelated methods.
Key Takeaway:
Choose utility class names that communicate purpose: use descriptive domain names for focused utilities, and reserve generic suffixes like Utils or Helper for broader collections of related operations.