Java – Difference between Handler, Manager and Controller

javanaming

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.

Best Answer

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.