Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's a good name for a façade class?

Tags:

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.)

like image 299
Daniel Pryden Avatar asked Jul 18 '11 18:07

Daniel Pryden


People also ask

What is another name of facade design pattern?

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.

What does a facade class do?

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.

What is a facade service?

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.

Can a facade call another facade?

Yes, you are right! Facade provides an interface of something complex, by hiding the complexity and haphazardness to its client.


2 Answers

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.

like image 94
Paul Sonier Avatar answered Sep 28 '22 10:09

Paul Sonier


How about *Provider and *Consumer? I think you said it yourself in your question. Perhaps *Producer and *Consumer is a better match?

like image 42
Ryan Stewart Avatar answered Sep 28 '22 10:09

Ryan Stewart