开发者

Web application layers help needed

I'm trying to figure out what are the layers that a web application needs in order to have a solid separation of concerns. I'm working with medium to big applications with entities that frequently interact with each other.

So far I have the following

  1. Entity Layer - Models the business entities and is used in across the app

  2. Repository Layer - Deals with persistence and all the calls to and from the database

  3. Service Layer - Deals with business requirements

  4. Controller Layer - Deals with the Requests and only calls Services

  5. View Layer

Also for every entity there is a dedicated Repository and a dedicated Service

My questions are the following:

  1. Is it ok if one Entity Service references another Entity Service or should the开发者_运维问答re be a new Service not bound to an Entity that uses the Entity Services?(this is a broader question: what is the interaction between layers)

  2. Should there be another layer between the Repository and the Services like a Manager(dedicated to an entity, containing business logic that pertains to that entity, just like the service in the original setup but only used but other Services) and a Service Layer that references the Manager Layer?(tbh this sounds overly complicated but if someone has some arguments for a Manager Layer and a Service Layer please tell me)

  3. Should the View Layer have access to the services that a Controller references?(in order to retrieve some lists or should all the information that a view needs be supplied by the controller?

Thank you

PS: I might ask more questions as I read the answers, if I think they're important I'll update the main post. PS2: I'd appreciate if you could share any personal experience regarding this issue.


  1. I would say yes, a service can collaborate with other services.
  2. No, this is an unnecessary over-complication.
  3. Controller really is a part of View; the two go together. It's possible that a view might call services, especially if you're doing a web UI with AJAX calls.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜