开发者

Service layer = Application layer = GRASP Controller layer [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 4 years ago.

Improve this question

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 开发者_如何学Pythonthis 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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜