Is there any difference between naming a class "Handler", "Manager" or "Controller"? IE: PurchaseManager, PurchaseHandler, PurchaseController.

Do these suffices convey the same meaning or is there a clear difference between them?

If there isn't a language-agnostic answer, consider Java as the language.

  • 1
    More context would be helpful here. Many (many!) frameworks have pretty clear definitions of the distinctions. However, there's no universal definition behind these words. What context are you working in? What framework are you using? What language are you using? – S.Lott Jun 7 '11 at 17:06
  • Clarified language. – hpique Jun 7 '11 at 17:12

Usually a 'Controller' is the interface between a user interface component and a model (e.g. Purchase). Controllers should be thin classes, doing little more than mapping user interface events to model functions.

A 'Manager' is a code smell. The purchase should manage itself, or it could be managed by an owning class, like Vendor or Buyer.

A 'Handler' is usually a single function wrapped in an object. These are needed when programming in legacy languages without first-class functions.

  • While I too don't like the concept of a 'Manager' I think the rationale for not having it handle its own business logic is that the programmer wants to separate a bean/pojo/dto from the complex business operations. – Sridhar Sarnobat Jul 23 '13 at 0:49
  • 1
    While I agree with you about Manager from a language agnostics point of view, I would like to add that a Manager can be correct term to use in some cases. For example it is ok to speak of managers from a protocol point of view for example. For SNMP you have a Manager "managing" a set of Agents. This is the correct term to use in this case. This does however justify spontaneous uses of "Manager". – patrik Mar 28 '17 at 8:15

While my answer is not based on definition, I view something labeled as a "Controller" as an exclusive implementation versus a "Handler" as inclusive. I would expect to see only one existence of a "PurchaseController" and multiple possible versions of a "PurchaseHandler".

I think another common name for Controller is "Broker" - which slightly alters the perspective on it.

  • Thank you for these definitions. You have put in a lot of knowledge in few lines. – acearch Feb 15 '19 at 6:00

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.