设计模式学习之路(一) 记住所有设计模式

虽然一直都想静下心来好好学习设计模式,但总是抽不出一个系统的时间来好好看看与之相关的书籍,直到最近项目提交完毕,才可以有一些间来好好学习下它的精华。

首次看到设计模式这个东西,感觉非常的高大上,总是认为自己学不会,其主要原因是我之前的工作一直用的都是C编程,可以说与设计模式相关的并不多,而且已经习惯了这种面向过程的开发方式,所以一直一来我都觉得很难学会,而且之前有曾接触过它,但是总是三天打鱼两天晒网,刚刚感觉略有心得,过一阵子不接触又还给书本了。目前换了一份新工作,涉及到一些JAVA编程,这激发了我想重新捡起GoF的书籍来努力学习的激情。

多年的学习经验告诉我,在学习一门新技术之前,必须要了解与之相关的Jargon。 翻开 Design Pattern 这本书,直接找到 1.4 The Catalog of Design Patterns 面对着这23种设计模式,咬咬牙,背诵之。

年近30的我,发觉记忆力大不如前,23种设计模式背完花了相当长的时间,过程很是辛苦,我每天上班第一件事就是打开word 默写一遍所有这23种设计模式,以增强记忆,但功夫不负有心人,经过我不断的努力,终于可以将这些条目背下来了,尽管没有办法做到一字不落,但还是可以说到了相当熟练的地步了。

这是我所学习的第一步,那就是  背诵。

总结个人经验就是,背英文相关的东西,最好的方就是多复习。


现在将它们写到博客里,留着以后复习之用。

1.      Abstract Factory – define an interface forcreating families of related or dependent objects without specifying theirconcrete classes.

2.      Adapter – convert the interfaces of an object toanother the clients expect. Adapter makes classes work together that couldn’totherwise because of incompatible interfaces.

3.      Bridge --separate an abstraction from its representation so that the two can varyindependently.

4.      Builder – separate the construction of a complexobject from its representation, so that the same construction process cancreate different representations.

5.      Chain of responsibility – avoid coupling thesender of a request from its receiver by providing more than one object achance to handle it. Chain the receiving objects and pass the request along thechain until an object handles it.

6.      Composite – Compose object into tree-likestructure to represent part-whole hierarchies. Composite lets clients treatindividual objects and compositions of object uniformly..

7.      Command – encapsulate a request as an object, therebyletting you parameterize clients with different request, queue or log requestsand support undoable operations.

8.      Decorator – attaches different responsibility toan object dynamically. Decorator provide a flexible alternative to subclassingfor extending functionality.

9.      Facade – provide a unified interface to a set ofinterfaces in a subsystem. Facade defines a hither-level interface that makessubsystem easier to use.

10.  Factory Method – define an interface forcreating objects but let subclasses decide which class to instantiate. FactoryMethod lets a class defer its instantiation to subclasses.

11.  Flyweight – use sharing to support large numberof fine-grained objects efficiently.

12.  Iterator – provide a way to access the elementsof an aggregate object sequentially without exposing its underlyingrepresentation.

13.  Interpreter – given a language, define arepresentation for its grammar along with an interpreter that uses thisrepresentation to interpret sentences in this language.

14.  Mediator – define a object that encapsulate howa set of objects interact, Mediator promotes loose coupling by keeping objectsreferring to each other explicitly, and it lets you vary their interactionindependently.

15.  Memento – without violating encapsulation,capture and externalize the internal state of an object, so that it can berestored to this state later.

16.  Observer – define a one-to-many dependentbetween objects, so that when object changes state all of its dependents arenotified and updated automatically.

17.  Prototype – specify the kinds of objects tocreate using a prototypical instance, and create new objects by copying thisprototype.

18.  Proxy – provide a surrogate or placeholder to anobject to control access to it.

19.  Singleton – ensure a class only has one objectand provide a global point of access to it.

20.  State – allow object to alter its behavior whenits internal state changes. Objects will appear to change its class.

21.  Strategy – define a families of algorithmsencapsulate each one and make them interchangeable. Strategy lets the algorithmvary independently from clients that use it.

22.  Template Method – define the skeleton of anobject in an operation, deferring some steps to subclasses. Template Methodlets subclass redefine certain steps of an algorithm without changing thealgorithm’s structure.

23.  Visitor – represent the operation to beperformed on the elements of an object structure, visitor lets you define a newoperation without changing the classes of objects on which it operates.


你可能感兴趣的:(设计模式,design,patterns,设计模式,技术,博客)