今天开始读设计模式-可复用面向对象软件的基础(Design Patterns-elements of reusable Object-Oriented Software)
这本书第一次的提出设计模式,经典的23种设计模式,他们总结别人用到的设计模式,并进行讲解.
2012.6.7
听说设计模式可以用于任何场合,不管面向对象和面向过程的,还有人拿设计模式这本书中的话作为依据,但是我看了Introduction 部分,发现这么几句:
1. The purpose of this book is to record experience in designing object-oriented software as design patterns. Each design pattern systematically names, explains,
and evaluates an important and recurring design in object-oriented systems. Our goal is to capture design experience in a form that people can use effectively.
To this end we have documented some of the most important design patterns and present them as a catalog.
2. None of the design patterns in this book describes new or unproven designs. We have included only designs that have been applied more than once in different
systems. Most of these designs have never been documented before. They are either part of the folklore of the object-oriented community or are elements of some
successful object-oriented systems—neither of which is easy for novice designers to learn from. So although these designs aren't new, we capture them in a new
and accessible way: as a catalog of design patterns having a consistent format.
3. Despite the book's size, the design patterns in it capture only a fraction of what an expert might know. It doesn't have any patterns dealing with concurrency
or distributed programming or real-time programming. It doesn't have any application domain-specific patterns. It doesn't tell you how to build user
interfaces, how to write device drivers, or how to use an object-oriented database. Each of these areas has its own patterns, and it would be worthwhile for someone
to catalog those too.
4. Although design patterns describe object-oriented designs, they are based on practical solutions that have been implemented in mainstream object-oriented
programming languages like Smalltalk and C++ rather than procedural languages (Pascal, C, Ada) or more dynamic object-oriented languages (CLOS, Dylan, Self).
We chose Smalltalk and C++ for pragmatic reasons: Our day-to-day experience has been in these languages, and they are increasingly popular.
可见这本书中的设计模式应该是面向对象设计的,应该不是用于C语言这种面向过程的!!
找到另外一本书 :design pattern for embedded system in c,中文译本为C嵌入式编程设计模式,读一读,看一看!
2012.6.8
5.Design Pattern根据purpose和scope来分类.
6.Object composition is an alternative to class inheritance. Here, new functionality
is obtained by assembling or composing objects to get more complex functionality.
Object composition requires that the objects being composed have well-defined
interfaces. This style of reuse is called black-box reuse, because no internal
details of objects are visible. Objects appear only as "black boxes."
7.Object composition is defined dynamically at run-time through objects acquiring
references to other objects.
第二章 A case study
1. 想到编写一个图形和文本混合编辑的处理程序,都是很麻烦的。简单的文本处理程序,像notepad++都是如此的难写,需要付出多大的努力。
2. 这章讲述一个文本编辑器设计中,如何使用设计模式。真的不错,但是看得不太明白。
3. 感觉架构设计比较粗,而设计模式比较细,是关于如何具体实现的。先架构设计,然后具体实施时使用设计模式。
第三章 Creational Patterns
1.
2012.12.13