views:

58

answers:

2

I found a thesis on forums:

If you have a type with "Manager" in the name, it's a candidate for refactoring.

One answer:

I know it's considered a code "smell"

So... Why? Is this thesis correct?

There are many managers out there. For example, Ogre3d uses them a lot, and this engine really has a clean architecture.

+2  A: 

Ogre3d uses them a lot, and this engine really has a clean architecture.

It does everywhere except the "manager" classes. Look at DefaultSceneManager as an example. These are incredibly huge, nightmarish classes to "manage."

The problem is that most classes with a name including "Manager" typically violate the Single Responsibility Principle. This isn't always true - as a class may have the single responsibility of managing one other aspect, but typically, those will be named differently. When a class gets the name "Manager", it's typically because it's the class overseeing everything - and really should be broken into distinct pieces based on their individual responsibilities.

Reed Copsey
Wow, 100k rep, you are awesome :)
topright
Please, name common responsibilities of Manager class that could be splitted? Creating, caching, ... I admit, `DefaultSceneManager` looks really horrible.
topright
@topright: It completely depends on the "manager" class in question. The idea is to try to make your classes do one thing, and do it well... not "manage" all of the operations of your program. That's the basic idea here.
Reed Copsey
I agree , it's relative. For example, if you follow the "Method" suggested here http://www.idesign.net/idesign/DesktopDefault.aspx, Manager has a very clear meaning and does a very descent single responsibility work. So as @Reed also mentioned, we cannot always say that "Manager" smell.
Subhash Dike
A: 

A Manger when doing lot of things is a smell. If we carefully look into the Manager on what it is doing then you may find lot the things a service does. Splitting, separating them and extract into different a Services makes sense.

You can also find some SRP classes having named suffixed with Manager like 'ConnectionPoolManager'. This makes sense if it does what it says.

Ashok