开发者

Differences between Facade Pattern and other patterns

I have a question about patterns. I really have problems with des开发者_运维技巧ign patterns. Can you tell me the differences between Facade Pattern and Builder, Factory and Abstract Factory patterns?


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.


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

The Builder pattern separates 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 instantiating a related set of classes based on certain parameters used when the call to the Factory is made.


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 the 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 or instantiation of an object or object graph.

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜