I still remember that around mid 2013, I was arguing for the same concept of Facade layer in our application in my earlier company. I was unable to digest the importance of Facade layer, so I was of firm opinion that Facade layer is unnecessary and should not be used!!
After 3 years, today when I was working on some code I realized that if we would have used Facade layer in our application then my work would have been much simpler than what I was doing...
After 3 years, today when I was working on some code I realized that if we would have used Facade layer in our application then my work would have been much simpler than what I was doing...
Structure of our application -
Controllers/CommandHandlers
| <----- Aspect execute at here
Service Layer
|
Accessor/DAO
| |
DB Server
This is the structure of our application, in which Service layer handles the gathering and processing of data from DB and server process.
We have a concept of MSU, where our application hosted of a central server gathers data from various servers and shows it on the centralized server. Now when call from controller or command handler goes to service layer, our custom Aspect comes into picture and performs the same operation for various servers mapped into our application.
- Local only
- Local or remote
- Local and remote
- Remote only
Depending upon the parameter configured in the Annotation aspect, this aspect executes this call of service layer on various servers.
Today when I was working on one of call, which has very heavy processing in service layer I remembered my discussion with one of my colleague or rather my oppose to the use of Facade layer in our application.
I realized that, it would have been very much beneficial if we would have had the following kind of structure of our application.
Controllers/CommandHandlers
| <----- Aspect would have executed here
Facade Layer
|
Service Layer
|
Accessor/DAO
| |
DB Server
In this case it would have been so easy for our to intercept the facade calls and execute them on various servers without worrying about the heavy processing in the service layer. Well, I would like to also add the point which my colleague was telling me in this discussion, that Facade layer helps to write more testable code(I still do not agree fully on this point yet).
But surely it helps to segregate the code from the service layer and controller layer which can be very helpful in situations like us.
Comments
Post a Comment