views:

260

answers:

3

Hi,I have a question about patterns.I have really problems with design patterns Can you tell me the difeerences between facade pattern with builder,factory and abstract factory pattern?

+1  A: 

The Facade pattern abstracts details away from the developer and makes a certain portion of code easier to use.

The Builder pattern seperates the construction of an object from its representation. That makes it possible to use the same construction process across multiple types.

The Factory and Abstract Factory both deal with instanciating a related set of classes based on certain parameters used when the call to the Factory is made.

Justin Niessner
So I looked it up http://www.dofactory.com/Patterns/PatternFacade.aspx#_self1 and as is usually the case with patterns I thought: I probably used the pattern somewhere without knowing what it is called.
Hamish Grubijan
+1  A: 

The facade pattern is used when you want to hide an implementation or otherwise make available a different interface externally. The builder/factory pattern is used when you want to hide the details on constructing instances.

Kelly French
A: 

Those and also other patterns might often look quite similar. The difference is in the design decisions you made to use a pattern.

Facade is about changing interface of some class or set of classes. Builder hides the process of construction by decomposing it in smaller steps. Factories are about hiding the concrete implementation of instation of object or object graph.

The confusion might come from the fact, that often Builder in a way changes interface of an object to allow better way of construction, which could be also done by a Facade. Similar it is with Factories.

So don't forget about small differences in implementation of those patterns and that the most important part about design patterns are the design decision you make.

Gabriel Ščerbák