A little background: We're building a library/framework for working with scientific models. We have an interface Model
which defines the operations that a model must implement, which is pretty minimal. That is: the Model
interface defines the contract of a model from the point of view of a model implementor.
The framework adds a bunch of other functionality around the model, but right now client code has to access that functionality by using a bunch of other classes, such as ModelInfo
, ModelHost
, ModelInstance
, etc.
In our application that uses this framework, we don't want to actually have to deal with all this mechanism of running models, etc. So we've decided to use the façade pattern to wrap up the framework functionality in an easy-to-use object. (We've already applied this pattern to other parts of the framework, with good success.)
Here is the question: given that we already have an interface Model
, what would be a good name for the façade class? The Model
interface is the contract between the framework and the model implementation, and the new class will define the contract between the framework and the client application.
Or, more generally: when we have an abstraction provided by a library or framework, how can we name the "two sides" of the abstraction so as to clearly identify the "provider" and "consumer" interfaces to the abstraction?
(If it matters, for this project we're using Java 6.)
The facade pattern (also spelled façade) is a software-design pattern commonly used in object-oriented programming. Analogous to a facade in architecture, a facade is an object that serves as a front-facing interface masking more complex underlying or structural code.
A facade is a class that provides a simple interface to a complex subsystem which contains lots of moving parts. A facade might provide limited functionality in comparison to working with the subsystem directly.
A facade is a way of wrapping up anything (including a service) to present it nicely to another component. Facades are often used when: A library or component is complex and your application needs only a subset of it. Your Facade presents the simplified API to the application.
Yes, you are right! Facade provides an interface of something complex, by hiding the complexity and haphazardness to its client.
I know this seems trite, but... have you considered using "ModelFacade
" as the class name for the facade class? I think with documentation that indicates that the interface was already named Model
, it seems relatively straightforward, and makes it very clear which design pattern you're using.
How about *Provider and *Consumer? I think you said it yourself in your question. Perhaps *Producer and *Consumer is a better match?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With