Utility

Problem

What's the difference between a function and a method? Technically, methods have an implicit parameter (this) which refers to the object that "owns" the method. A method describes some behavior of its owner. For example, the withdraw and deposit methods of a bank account object describe how its balance changes. On the other hand, a function simply describes an algorithm rather than a behavior. For example, trig functions like sine and cosine aren't object behaviors.

We still need functions in some object-oriented programs, but we don't want to implement these functions as methods of some meaninglessobject.

Solution

Related functions and constants are implemented as static members of a utility class:

A utility class (also called a service) only contains static members.