我们通过一个例子来引出Builder模式.假设有一个Person类,我们通过该Person类来构建一大批人,这个Person类里有很多属性,最常见的比如name,age,weight,height等等,并且我们允许这些值不被设置,也就是允许为null,该类的定义如下. 1234567891011121314151617181920212223242526272829303132333435363738 public class Person { private String name; priv
今天介绍下策略模式,直接先上UML图 策略模式的概念 The Strategy Pattern defines a family of algorithms,encapsulates each one,and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.–(翻译)– 定义一系列的算法,把它们一个个封装起来, 并且使它们可相互替换.策略模式使得