In our application (C#), the facade is used as the core’s API – the facade will be used by the App itself to do stuff with the core. Knowing that, here are my questions:
- Assuming one of my core objects, which the facade wraps, has a recursive bit in it? For example, the facade provides a ‘GetX’ from a tree, and each node needs to GetX from its subtree. Should this node use the facade’s ‘GetX’?
- Should the facade expose core objects to the application? E.g., the user wants to build a tree, add nodes, print the tree, calculate things on it etc. Should the application use the tree object or should it ask the facade to create it, save it, pring it etc.?
Thanks.
Therefore, keep it simple.
No. Encapsulate the Facade within itself. I assume you have a private implementation for retrieving the tree, use this internally, exposing only the public method which returns the populated object (see point 2).
No. The facade should do everything, otherwise there is little point creating it. You might want to create a DTO that can be used within the facade methods, but you should not expose the core objects.