`
文章列表
      呵,从翻译这个标题开始这个模式学习吧: The use of layered objects to dynamically and transparently add responsibilities to individual objects is referred to as the decorator pattern.--利用多层对象动态、透明地给一个对象添加功能,称之为 ...
     恍然间,发现自己在这个行业里已经摸爬滚打了五年了,原以为自 己就凭已有的项目经验和工作经历怎么着也应该算得上是一个业内比较资历的人士了,但是今年在换工作的过程中却遭到了重大的挫折。      ...
The odd thing about flyweight, in the company of the other design patterns, is that it’s a performance hack. It’s generally ideal to simply make an object for every item in your system, but some problems generate a prohibitive number of objects, which may result in excessive slowness or running o ...
The goal of builder is to separate the construction from the “representation,” to allow multiple different representations . The construction process stays the same, but the resulting object has different possible representations.GoF points out that the main difference with Abstract Factory is t ...
//工厂方法的理解比较容易,重要还是如何在实践中应用。以下范例比较经典:   基本概念      FactoryMethod是一种创建性模式,它定义了一个创建对象的接口,但是却让子类来决定具体实例化哪一个类.当一个类无法预料要创建哪种类的对象或是一个类需要由子类来指定创建的对象时我们就需要用到Factory Method 模式了.简单说来,Factory Method可以根据不同的条件产生不同的实例,当然这些不同的实例通常是属于相同的类型,具有共同的父类.Factory Method把创建这些实例的具体过程封装起来了,简化了客户端的应用,也改善了程序的扩展性,使得将 ...
An application framework allows you to inherit from a class or set of classes and create a new application, reusing most of the code in the existing classes and overriding one or more methods in order to customize the application to your needs. A fundamental concept in the application framework i ...
Although GoF says that Policy is just another name for strategy, their use of Strategy implicitly assumes a single method in the strategy object – that you’ve broken out your changing algorithm as a single piece of code. ....   It also seems generally useful to distinguish Strategies with sing ...
<第一部分> 学过任何一门程序语言的人都会知道,一个可执行程序的形成要经过的步骤是: 编辑 ---> 编译 形成 .obj 文件 ---> 链接形成 .exe 文件。 那么计算机程序到底是怎样运行的呢?上面的简单过程我相信都可以想到。但是其实质,需要这些步骤的理由是什么?我们有没有想过呢? 首先当然是编程,需要的是程序设计语言。现在大多数我们都是使用 java,c,c++ 等高级程序语言。但是计算机所能识别的知识计算机语言即二进制代码。这需要编译器和汇编器的帮助。其次,机器语言需要加载到内存,形成运动中 ...
Strategy : choosing the algorithm at run-time Strategy also adds a “Context” which can be a surrogate class that controls the selection and use of the particular strategy object—just like State ! Here’s what it looks like: //: strategy:StrategyPattern.java package strategy; import com ...
In the process, he realized that iterators are central to the use of algorithms, because they decouple the algorithms from the specific type of containe...只看这个,不是很好理解。 找了两个资料,感觉是比较好的例子: <1> Iterator模 ...
An object that appears to change its class. Indications: conditional code in most or all methods. The State pattern switches from one implementation to another during the lifetime of the surrogate, in order to produce different behavior from the same method call(s). It’s a way to improve the imp ...
基本概念 Singleton 是一种创建性模型,它用来确保只产生一个实例,并提供一个访问它的全局访问点.对一些类来说,保证只有一个实例是很重要的,比如有的时候,数据库连接或 Socket 连接要受到一定的限制,必须保持同一时间只能有一个连接的存在.再举个例子,集合中的 set 中不能包含重复的元素,添加到set里的对象必须是唯一的,如果重复的值添加到 set,它只接受一个实例.JDK中正式运用了Singleton模式来实现 set 的这一特性,大家可以查看java.util.Collections里的内部静态类SingletonSet的原代码.其实Single ...
java动态代理(JDK和cglib) JAVA的动态代理  代理模式  代理模式是常用的java设计模 式,他的特征是代理类与委托类有同样的接口,代理类主要负责为委托类预处理消息、过滤消息、把消息转发给委托类,以及事后处理消息等。代理类与委托类之间 通常会存在关联关系,一个代理类的对象与一个委托类的对象关联,代理类的对象本身并不真正实现服务,而是通过调用委托类的对象的相关方法,来提供特定的服 务。  按照代理的创建时期,代理类可以分为两种。  静态代理:由程序员创建或特定工具自动生成源代码,再对其编译。在程序运行前,代理类的.class文件就已经存在了。  ...
The Design Patterns book discusses 23 different patterns, classified under three purposes (all of which revolve around the particular aspect that can vary). The three purposes are: 1.              Creational : how an object can be created. This often involves isolating the details of ...
    用于实现两个线程之间的数据交换,每个人在完成一定的事务后想与对方交换数据,第一个先拿出数据的人要一直等待第二个人拿着数据到来时,才能彼此交换数据     import java.util.concurrent.Exchanger; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors;   public class ExchangerTest {       ...
Global site tag (gtag.js) - Google Analytics