tags:

views:

122

answers:

7

Following Alan Green's "Naming Java classes without Manager" I've started hunting *Manager classes in my own code.

How would you rename the following class? ServiceLoader, maybe? but it doesn't "load" anything from anywhere.

class ServiceManager
{
    public bool IsRunning { get; };
    public void Start();
    public void Restart();
    public void Stop();
}

Also, please share your own examples of Manager classes that you've renamed.

Thanks

+1  A: 

Maybe ServiceController? ServiceWrapper?

Pwninstein
I like ServiceController, I'll think about it. Thanks
Julio César
A: 
  • ServiceMonitor?
  • ServiceController?
Kon
+1  A: 

While that article is relevant, I don't see an issue with the name ServiceManager

Service also works, but perhaps you need to be more specific - in a namespace. It looks to me like a Windows/NT service - so maybe just Service in your own descriptive namespace.

Having thought about it more - just plain old Service seems most appropriate. with a namespace of your choosing.

Tim
Yes, the class is shared between a Windows Service and a desktop application to start some .NET Remoting services.
Julio César
+4  A: 

Does the Manager part add anything? Why not just 'Service'.

edit:

To clarify, it doesn't seem like this manages, or controls, or does anything to, a service. It reads like it is the service.

If it was doing anything to, or for, a service, then I'd expect to be able to get the service object it controlled and call methods on that too.

If this was a controller interface that you could get from a Service object, that would be different.

frankodwyer
That's a very good suggestion. After reading all answers I'm considering leaving it as just "Service". But I'll wait for other suggestions first.
Julio César
+1  A: 

If this is the service class itself, I would rename to be descriptive of the type of service it provides, i.e., BookingService, OrderProcessingService, PrintAccountingService. If it is a generic class that controls different types of services, then I would suggest that either ServiceController or ServiceManager are appropriate. Since you express a preference not to use Manager, then I would go with the former.

What are you going to do, though, if someone writes an article that says you ought to get rid of all those "Controller" class names? Bottom, line -- the class name ought to help you understand what the class does. If it's working already, don't bother renaming just to meet someone else's opinion.

tvanfosson
I just happen to agree with his point that "Manager" doesn't actually describe what a class does. Like in this case, ServiceManager doesn't told you what the class did.
Julio César
A: 

I probably should have described a little more what the class does. This class starts/stops a .NET Remoting service.

The Start() method registers a channel (port) and the interfaces for the services.

Julio César
A: 

This class starts/stops a .NET Remoting service.

Then I would name it DotNETRemotingService...

Technically, it is a wrapper around that service... but then for all intents and purposes, within your code this IS the service, and therefore deserves to be handled as such.

metao