设计模式(Design Patterns) ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结。使用设计模式是为了可重用代码、让代码更容易被他人理解、保证代码可靠性。 毫无疑问,设计模式于己于他人于系统都是多赢的, ...
分类:
编程语言 时间:
2020-06-30 12:50:59
阅读次数:
60
装饰器模式(Decorator Pattern)允许向一个现有的对象添加新的功能,同时又不改变其结构。这种类型的设计模式属于结构型模式,它是作为现有的类的一个包装。这种模式创建了一个装饰类,用来包装原有的类,并在保持类方法签名完整性的前提下,提供了额外的功能。我们通过下面的实例来演示装饰器模式的用法 ...
分类:
Web程序 时间:
2020-06-30 12:40:18
阅读次数:
74
Question Theory An Example // Expression.java import java.util.HashMap; public abstract class Expression { public abstract int interpreter(HashMap<Str ...
分类:
其他好文 时间:
2020-06-29 18:29:08
阅读次数:
56
Wildcard Matching (H) 题目 Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. '?' Matches an ...
分类:
其他好文 时间:
2020-06-29 09:44:44
阅读次数:
51
菜瓜:今天听到个名词“父子容器”,百度了一下,感觉概念有点空洞,这是什么核武器? 水稻:你说的是SpringMvc和Spring吧,其实只是一个概念而已,用来将两个容器做隔离,起到解耦的作用,其中子容器可以拿到父容器的bean,父容器拿不到子容器的。但是SpringBoot出来之后这个概念基本就被淡 ...
分类:
编程语言 时间:
2020-06-29 00:09:41
阅读次数:
73
名称: 命令模式(Command Pattern) 问题: The Command pattern encapsulates a request in an object, which enables you to store the command, pass the command to a m ...
分类:
其他好文 时间:
2020-06-28 22:12:34
阅读次数:
80
名称: 策略模式(Strategy Pattern) 问题: The intent of the Strategy Pattern is to define a family of algorithms, encapsulate each algorithm, and make them inter ...
分类:
其他好文 时间:
2020-06-28 20:11:35
阅读次数:
55
问题 Solve // Action.java public abstract class Action { public abstract void getManResult(Man man); public abstract void getWomanResult(Woman woman); } ...
分类:
其他好文 时间:
2020-06-28 18:58:17
阅读次数:
56
策略模式 在策略模式(Strategy Pattern)中,一个类的行为或其算法可以在运行时更改。这种类型的设计模式属于行为型模式。 在策略模式中,我们创建表示各种策略的对象和一个行为随着策略对象改变而改变的 context 对象。策略对象改变 context 对象的执行算法。 介绍 意图:定义一系 ...
分类:
其他好文 时间:
2020-06-28 18:45:49
阅读次数:
49
模板模式 在模板模式(Template Pattern)中,一个抽象类公开定义了执行它的方法的方式/模板。它的子类可以按需要重写方法实现,但调用将以抽象类中定义的方式进行。这种类型的设计模式属于行为型模式。 介绍 意图:定义一个操作中的算法的骨架,而将一些步骤延迟到子类中。模板方法使得子类可以不改变 ...
分类:
其他好文 时间:
2020-06-28 18:35:06
阅读次数:
64