mercredi 3 juillet 2019

Controller -> Service -> Dao : Difference in Responsibilities between Controller/Service layer [duplicate]

This question already has an answer here:

While writing an app, I have structures it in 3 different layers;

1. Controllers (Orchestrator which controls the flow by invoking one or more services).
2. Service layer (May use one or more DAO's to serve one abstract functionality).
3. Dao : Standard Data access objects, to abstract the underlying data-source

I am unable to figure out the difference in responsibilities between service/controller layers. As per my understanding, Service itself sometimes tend to act as a sub-controller , controlling the sequence of multiple DAO invocations.

Question :

Is Service layer really needed when we already have a Controller which can interact with DAO's directly.

Is there some benefit which we can achieve while using Controller -> Service -> DAO. Or we can do away with Service, having only only Controller -> DAO.

Aucun commentaire:

Enregistrer un commentaire