后缀服务,管理器,系统有什么区别?
我很好奇服务、管理器和系统之间的区别。
我一直试图避免使用此类后缀。但在我开始使用 MVC 后,我需要创建一个单独的类,以免每次从任何脚本调用函数时都访问控制器。系统提示我使用 Service 类从任何脚本中引用它。据我了解,使用控制器作为单独的实体仅用于处理事件(我理解正确吗?): 如何从另一个控制器使用一个控制器在MVC中
从上面链接的示例中,我有一个SpeakerController,它接受事件并将其定向到执行某些功能的SpeakerService。
为什么需要命名为SpeakerService,而不仅仅是Speaker?从OOP原理的名称中,我一直只看到类的名词,没有后缀。
我期望有一个更具可读性的程序,其名称不言而喻。我尝试过使用 Manager 和 Service 后缀,但我不明白它们的概念必要性
I'm curious about the difference between Service, Manager and System.
All the time I tried to avoid such suffixes. But after I started working with MVC, I needed to create a separate class so as not to access the controller every time from any script to invoke a function. I was prompted to use the Service class to refer to it from any script. And as I understood using controllers as separate entities only for handling events (Did I understand correctly?):
How to use a controller from another controller in MVC
From the example on the link above, I have a SpeakerController which accepting an events and directing it to SpeakerService that performs certain functions.
Why it was necessary to name SpeakerService, and not just Speaker? From the names of the OOP principle, I have always seen only a noun for the class without suffixes.
I expect a more readable program where the name speaks for itself. I have tried using the Manager and Service suffixes but I don't understand their conceptual necessity
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我们编写软件时,我们需要一种分离类的方法。如果我们将所有类放在一个文件夹/项目中,那将是一团糟。
所以几乎所有程序都必须:
Service
。View
。所以对我来说:
聊天系统
的UserManager
可以有以下方法,例如GetUserById
、GetOnlineUsers()
、AddUser ()
、UserLogin()
、UserLogoff()
更新:
我在 ASP.NET MVC 中看到了服务。这是一个简单的示例:
这是一个模型:
和视图模型:
这些是存储库:
以及我们的服务:
和控制器方法:
使用管理器的示例
让我们创建一个聊天应用程序。 oop 模型可能如下所示:
User
类:Message
类:Topic
类:Status
枚举:ChatSystem
类:UserManager
类:When we write software, we need a way to separate classes. If we put all classes in one folder/project, it would be a complete mess.
So almost all programs have to:
Model
.Service
.View
.So for me:
UserManager
forChat System
can have the following methods such asGetUserById
,GetOnlineUsers()
,AddUser()
,UserLogin()
,UserLogoff()
UPDATE:
I saw services offen in ASP.NET MVC. So this is a simple example:
This is a model:
And view models:
These are repositories:
and our service:
and controller method:
An example of using manager
Let's create a chat application. The oop model could look like this:
User
class:Message
class:Topic
class:Status
enum:ChatSystem
class:UserManager
class: