服务层=应用层=GRASP控制器层 [英] Service layer = Application layer = GRASP Controller layer

查看:20
本文介绍了服务层=应用层=GRASP控制器层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为服务/应用层与 Larman 所描述的 GRASP 控制器是一样的,它是 GUI 层之外委托给域层的第一个对象,并且应该可以从不同的 GUI 中重用.

Service (Evans) 层与 Application (Fowler) 层相同,因为 Fowler 在他关于贫血域模型"的bliki"中是这么说的:http://martinfowler.com/bliki/AnemicDomainModel.html

引用:应用层[他的服务层名称]:定义工作软件应该做并指导富有表现力的领域对象解决问题.该层负责的任务是对业务有意义或需要与其他系统的应用层.该层保持薄.它确实不包含业务规则或知识,只包含协调任务并将工作委托给下一个领域对象的协作层下来.没有反映营业状况的状态,但它可以具有反映任务进度的状态用户或程序."

现在考虑上面的描述(另请参阅 fowler 的 PEAA 书,关于从用例中识别服务层方法),并考虑 Fowler 对服务层的描述中的图片,该图片说明服务层是用户"之后的第一层接口"在此 URL:http://martinfowler.com/eaaCatalog/serviceLayer.html>

现在比较上面提到的Service/Application层描述拉曼关于 GRASP 控制器的一些话(在第三他最畅销的 OOAD 书籍Aplying UML 和模式"的版本,年龄302-306):... UI 层之外的第一个接收和坐标的对象(控制")一个系统操作……"...代表一个用例场景,其中系统事件发生……"...通常,控制器应该将工作委托给其他对象这需要做;它协调或控制活动.它本身并没有做太多工作......"

我觉得Larman的GRASP Controller层和Evans/Fowler 的应用程序/服务层.其他人不同意吗?然后请解释这些概念之间的显着差异,以及一些Controller类而不是Service/Application类的例子.

我的问题诞生是因为有人说模型域对象的创建是控制器的责任,而不是其他服务/应用程序层.但是你能给我一个服务层类和控制器类之间的区别的例子吗?

解决方案

实际上,UI 控制器和域控制器是最常用的模式.

UI 控制器以 MVC 模式协调对视图的访问.

域控制器协调对域的访问,它被称为服务层(我更喜欢 Fowler)或应用层(Evans).

两者都是间接层(Façade Pattern),用于在子系统/层之间解耦类.它带来了模块化和更好的可维护性(您可以将域交换为远程服务或将视图从 HTML 交换为 Flex,只需更改间接层)

GRASP 控制器似乎是两者的混合体.我建议您将此术语仅用于分析,而不是用于实施.

希望能帮到你!

I think service/application layer is the same thing as Larman describes as GRASP Controller, being the first object beyond the GUI layer that delegates to the domain layer, and should be reusable from different GUI.

Service (Evans) layer is the same as Application (Fowler) layer because Fowler himself says so, in his "bliki" about the "Anemic Domain Model": http://martinfowler.com/bliki/AnemicDomainModel.html

Quote: "Application Layer [his name for Service Layer]: Defines the jobs the software is supposed to do and directs the expressive domain objects to work out problems. The tasks this layer is responsible for are meaningful to the business or necessary for interaction with the application layers of other systems. This layer is kept thin. It does not contain business rules or knowledge, but only coordinates tasks and delegates work to collaborations of domain objects in the next layer down. It does not have state reflecting the business situation, but it can have state that reflects the progress of a task for the user or the program."

Now consider the above description (and also see fowler's PEAA book, regarding identifying service layer methods from the use cases) and also consider the picture in Fowler's description of Service layer that illustrates the Service Layer being the first layer after the "user interface" at this URL: http://martinfowler.com/eaaCatalog/serviceLayer.html

Now compare the above mentioned Service/Application layer description with some of Larman's words about the GRASP Controller (in the 3rd edition of his best-selling OOAD book "Aplying UML and patterns", age 302-306) : "...first object beyond the UI layer that receives and coordinates ("controls") a system operation..." "...represents a use case scenario within which the system event occurs..." "... Normally, a controller should delegate to other objects the work that needs to be done; it coordinates or controls the activity. It does not do much work itself...."

I think that Larman's GRASP Controller layer is the same as Evans/Fowler's Application/Service layer. Do other people disagree ? Then please explain the significant differences between these concepts, and some example of Controller class instead of Service/Application class.

My question is born because some say that the creation of model domain objects is the responsibility of the controller, instead of the other service / application layer. But could you give me an example of service layer class and the difference between controller class?

解决方案

Actually there's UI Controller and Domain Controller as most used patterns.

UI Controller coordinates access to View, in an MVC pattern.

Domain Controller coordinates access to Domain, and it's called Service Layer (Fowler, which I prefer) or Application Layer (Evans).

Both are indirection layers (Façade Pattern), used to decouple classes between subsystems/layers. It brings modularity and better maintainability (you can swap domain for remote services or swap view from HTML to Flex, and just change the indirection layer)

GRASP Controller appears to be an hybrid of both. I recommend you to use this term only for analysis, not for implementation.

Hope it helps!

这篇关于服务层=应用层=GRASP控制器层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆