I have recently seen an EJB code with a Facade pattern to provide some methods to be used in presentation layer (JSF). But in some part of the business logic, the methods of the Facade is called and have been used.
That seems a little strange to me since I think the Facade is supposed to serve the outer world not the internal functionality. Am I right or I got paranoid?
This is a rough (stupid) diagram to illustrate the situation:
No, you shouldn't in my opinion. The façade is there to regulate the interface between layers; it shouldn't be used from inside the layer as well.
And it shouldn't be necessary either. I'm assuming getProductById
delegates the call to some sort of repository which fetches the Product
. You can use dependency injection to inject your repository in the appropriate classes. In the small UML sample I drew up just now (it's been a while, forgive me if some connections aren't correct) I demonstrate this approach.
Now the Report
class has access to the ProductRepository
and can fetch the data from there instead of going through the Façade class.