Question

There is a JavaEE application which is layered like this from bottom-up:

Entity -> Data Access Object (DAO) -> Controller -> Facade

In this architecture, how Controllers are supposed to talk to each other? Can they call each other's method or it must be done through the DAO layer?

Was it helpful?

Solution

Assuming that Controllers represents the business layer in your case.

It is quite common for EJBs in the service layer to have a hierarchy of their own. While offering more general functionality as an API to clients and UI, EJBs can offer a fine-grained functionality to one another. So yes, objects of the same layer can talk to one another and are often designed to do so.

The rationale behind it is to abstract external API from internal functionality as well as to reduce duplication.

EDIT: Please do not stop hesitating when introducing new dependencies. There is often a downside with respect to coupling, testability and architectural consistency. You should never use a layer or even an object inside the same layer 'from below' - meaning from an object with lower abstraction to an object with a higher abstraction. Feeling uncertain is often a hint to look twice.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top