我是靠谱客的博主 冷傲舞蹈,最近开发中收集的这篇文章主要介绍【23种设计模式之】9.Facade外观模式——简述(类似于装饰器模式、对象适配器),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

练习源码:https://github.com/liaoooyx/Design-Patterns

核心思想依然是组合

类似于装饰器模式、适配器模式中的对象适配器。

通过一个门面类(Facade),以成员变量的方式持有其他多个类(组合),这些具有相同的方法,但提供不同的功能。用户通过这个门面类进操作。

参考:java设计模式之外观模式(门面模式)

参考:http://jargon.js.org/_glossary/FACADE_PATTERN.md
The Facade Pattern (or façade pattern) is a software design pattern commonly used with object-oriented programming. The name is by analogy to an architectural facade.

A facade is an object that provides a simplified interface to a larger body of code, such as a class library. A facade can:

  • make a software library easier to use, understand and test, since the facade has convenient methods for common tasks;
  • make the library more readable, for the same reason;
  • reduce dependencies of outside code on the inner workings of a library, since most code uses the facade, thus allowing more flexibility in developing the system;
  • wrap a poorly designed collection of APIs with a single well-designed API.

The Facade design pattern is often used when a system is very complex or difficult to understand because the system has a large number of interdependent classes or its source code is unavailable. This pattern hides the complexities of the larger system and provides a simpler interface to the client. It typically involves a single wrapper class which contains a set of members required by client. These members access the system on behalf of the facade client and hide the implementation details.

最后

以上就是冷傲舞蹈为你收集整理的【23种设计模式之】9.Facade外观模式——简述(类似于装饰器模式、对象适配器)的全部内容,希望文章能够帮你解决【23种设计模式之】9.Facade外观模式——简述(类似于装饰器模式、对象适配器)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(64)

评论列表共有 0 条评论

立即
投稿
返回
顶部