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
-
Entity Layer – Models the business entities and is used in across the app
-
Repository Layer – Deals with persistence and all the calls to and from the database
-
Service Layer – Deals with business requirements
-
Controller Layer – Deals with the Requests and only calls Services
-
View Layer
Also for every entity there is a dedicated Repository and a dedicated Service
My questions are the following:
-
Is it ok if one Entity Service references another Entity Service or should there 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)
-
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)
-
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 Answer