Wrapper vs facade design patterns - please help!

A

almurph

Hi,


I'm trying to get my head around the differences between a facade
design pattern and a adapter (aka wrapper) design pattern.
I think what I need a very simple common example of each to fully
understand the differences.

I realise that both simplfy the interface to a larger body of code -
but what is the difference, ie when should you use them?

I would appreciate any help/advice/examples that you may be able to
provide in this regards.

Thanking you,
Al.
 
S

sloan

As you will find, a few of the patterns overlap a little bit. Only
experience and trial and error get the subtle differences to come to light.


Before I searched a little bit, my initial reaction was

"The adapter is used to take method1,method2.method3 and turn it into a
different method, mainly so it can become a "concrete" under a certain
interface (or abstract class).

And that the fascade was to take something complicated, and turn it into
something simpler.

Of course the template pattern is subtly like (but also different) from the
fascade pattern.

Then you got me thinking, am I close to being right?

.......
http://en.wikipedia.org/wiki/Facade_pattern

//start quote
An Adapter is used when the wrapper must respect a particular interface and
must support a polymorphic behavior. On the other hand, a facade is used
when one wants an easier or simpler interface to work with.
//end quote


So I was pretty close with my initial response based on what the wiki
provides.
 
A

Arne Vajhøj

I'm trying to get my head around the differences between a facade
design pattern and a adapter (aka wrapper) design pattern.
I think what I need a very simple common example of each to fully
understand the differences.

I realise that both simplfy the interface to a larger body of code -
but what is the difference, ie when should you use them?

I would appreciate any help/advice/examples that you may be able to
provide in this regards.

They are rather different.

To quote from the GoF book:

"Adapter (139) Convert the interface of a class into another interface
clients expect."

"Facade (185) Provide a unified interface to a set of interfaces in
a subsystem."

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top