重命名我的 ServiceManager 类

发布于 2024-07-10 09:48:17 字数 569 浏览 6 评论 0原文

遵循 Alan Green 的“在没有 Manager 的情况下命名 Java 类”我开始了在我自己的代码中寻找 *Manager 类。

您将如何重命名下面的类? 也许是ServiceLoader? 但它不会从任何地方“加载”任何东西。

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

另外,请分享您自己的已重命名的 Manager 类示例。

谢谢


,我可能应该多描述一下班级的工作。 此类启动/停止 .NET Remoting 服务。

Start() 方法注册服务的通道(端口)和接口。

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


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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

不气馁 2024-07-17 09:48:17

Manager 部分是否添加任何内容? 为什么不只是“服务”。

编辑:

澄清一下,这似乎并没有管理、控制或对服务做任何事情。 读起来就像是服务。

如果它对服务或为服务做任何事情,那么我希望能够获取它控制的服务对象并调用它的方法。

如果这是一个可以从服务对象获得的控制器接口,那就不同了。

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.

缱绻入梦 2024-07-17 09:48:17

也许是服务控制器? 服务包装器?

Maybe ServiceController? ServiceWrapper?

就此别过 2024-07-17 09:48:17

如果这是服务类本身,我将重命名为描述它提供的服务类型,即 BookingService、OrderProcessingService、PrintAccountingService。 如果是控制不同类型服务的泛型类,那么我建议使用 ServiceController 或 ServiceManager 都合适。 既然您表示不喜欢使用 Manager,那么我会选择前者。

但是,如果有人写了一篇文章说你应该删除所有这些“控制器”类名,你会怎么做? 底线——类名应该帮助你理解类的作用。 如果它已经有效,就不必为了满足别人的意见而重新命名。

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.

逆蝶 2024-07-17 09:48:17

虽然那篇文章是相关的,但我没有看到名称 ServiceManager

Service 也有效的问题,但也许您需要更具体 - 在命名空间中。 在我看来,它就像一个 Windows/NT 服务 - 所以也许只是您自己的描述性命名空间中的服务。

再想一想 - 只是普通的旧服务似乎是最合适的。 具有您选择的名称空间。

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.

故事未完 2024-07-17 09:48:17
  • 服务监视器?
  • 服务控制器?
  • ServiceMonitor?
  • ServiceController?
荆棘i 2024-07-17 09:48:17

此类启动/停止 .NET
远程服务。

然后我将其命名为 DotNETRemotingService...

从技术上讲,它是该服务的包装器...但出于所有意图和目的,在您的代码中,这就是服务,因此值得如此处理。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文