In the semi-functional Java world, I see development methodologies that make heavy use of dependency injection and mocking frameworks to achieve high levels of unit test coverage. In order to achieve thread safety, behavior is encapsulated in objects which have no state and no side effects (except maybe writing to the logs). Sometimes I have seen this called an Anemic Domain Model and the objects called Behavior Objects.

Such a class is not intended to be inherited from, so it may be marked as final or sealed, and it has no super class, though it may implement an interface. A single instance of the object is meant to exist in memory at runtime and is shared across many threads.

I was wondering if there was a single word that could be used to describe such a class with no fields and only pure functions.

  • There are language specific names, such as "static class". – Frank Hileman Oct 30 '17 at 22:19

A class whose objects have no data member is a stateless class.


  • oracle glossary : "A stateless object saves no application data; it is idempotent. Each operation on the object is independent of any other operations."
  • SO answer : "Stateless object is an instance of a class without instance fields (instance variables). The class may have fields, but they are compile-time constants (static final)."
  • Object-Oriented Design Decisions: Stateful or Stateless Classes? : In this blog the author makes the case for stateless helper classes.
  • Might be good to quote from both of the linked sources, in case the links go dead in the future. – Greg Burghardt Oct 28 '17 at 18:30
  • @GregBurghardt good idea ! done ! – Christophe Oct 28 '17 at 21:13
  • 1
    Stateless classes don’t require that their functions be pure... – Telastyn Oct 28 '17 at 21:17
  • @Telastyn It is fully true that a stateless class doesn't impose pure function. However, as the class is stateless, unless the functions use some global objects, interact with stateful parameters, or make some IO, the risk of the side effects are limited. – Christophe Oct 28 '17 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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