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.

I've read somewhere that it's a bad idea to name classes after verbs (manager/browser/editor)

but what's the proper name for manager/browser/editor?

EDIT:

the problem is that system could turn in a big ball of "services" - tiny objects which does something specific and does not contain any data - which is bad (at least because it just queries other objects)

but I also need to be able add new "managers" easily (right now app needs to manage users, ftp accounts, mail accounts, etc.)

share|improve this question
add comment

migrated from stackoverflow.com Mar 21 '11 at 6:59

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 4 down vote accepted

The main reason why names ending in Manager or Browser or Editor are sometimes bad is that they're vague and unspecific, and don't say enough about what the FooManager class is actually doing with Foos.

For exactly that reason, there is no general answer to the question "what should they be replaced with?".

A class name should (so far as is possible given its brevity) say what an instance of the class does. If you really can't say anything more about what a FooManager does than that it manages Foos, then call the class FooManager (and consider whether perhaps its respponsibilities should be divided among multiple other classes with better-focused responsibilities). If you can say something more specific, and you can do so briefly, then that should indicate what name would be better.

(Of course if your class is called WebBrowser or TextEditor or SeniorManager then none of the above applies; that isn't the sort of thing the folklore about not giving classes that sort of name is aimed at. :-) )

share|improve this answer
    
so UserManager, MailAccountsManager, etc. are all ok? I was also thinking to factor some functionality together in their modules (UserModule - users, payments, MailModule - mail accs, mail aliases) and use dynamic adapters to attach them in the rest of system. - like AppSection(callback) where callback would point directly to some method on module –  Kamil Tomšík Mar 21 '11 at 1:34
    
It might be better to find something more informative than, say, UserManager (which is pretty vague about exactly what instances of the class are doing). See stackoverflow.com/questions/1866794/… for an earlier discussion of this. –  Gareth McCaughan Mar 21 '11 at 1:37
    
interesting discussion - thx for the link. Is then MailModule better idea (including CRUD for all mail entities?) - still it smells like duplication (add_mailaccount, add_mailalias, add_xxx) –  Kamil Tomšík Mar 21 '11 at 1:51
    
MailModule doesn't feel great to me either, but of course I haven't seen the rest of your system! –  Gareth McCaughan Mar 21 '11 at 1:55
    
A-ha :-) closer the program models the real world problem, the better the program will be. - so the right object should be application, right? because it does all of the work –  Kamil Tomšík Mar 21 '11 at 2:07
show 1 more comment

"Manager", "Browser", and "Editor" are nouns, not verbs. "Manage", "Browse", and "Edit" are verbs, and not particularly good class names!

share|improve this answer
    
read edit why it's bad –  Kamil Tomšík Mar 21 '11 at 1:36
add comment

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.