Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
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
    

2 Answers 2

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.

share|improve this answer
    
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

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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