设计,总是说起来头头是道,真的等你设计的时候,又完全不是那么回事。学习设计模式,理解背后的设计思想和原则是很重要的。这里把Robert .C. Martin的文章罗列一下。
The Single Responsibility Principle
This principle discusses the need to place things that change for different reasons in different classes.
http://www.objectmentor.com/resources/articles/srp.pdf
The Interface Segregation Principle
Fat class interfaces are all too common. This article describes a principle that helps designers partition fat classes into multiple interfaces.
http://www.objectmentor.com/resources/articles/isp.pdf
The Open Closed Principle
Probably the most important of all the OOD principles. This article is an explanation and demonstration of Bertrand Meyer's famous principle.
http://www.objectmentor.com/resources/articles/ocp.pdf
The Liskov Substitution Principle
How do you know if you are using inheritance correctly? This article describes Barbara Liskov's famous 'Substitution Principles'. It shows the principle in action through several demonstrations.
http://www.objectmentor.com/resources/articles/lsp.pdf
The Dependency Inversion Principle
I first stumbled on this principle when Jim Newkirk and I were arranging the source code directories of a C++ project. We realized that we could make the directories that contained detailed code depend upon the directories that contained abstract classes. This seemed like an inversion to me, so I coined the name "Dependency Inversion".
http://www.objectmentor.com/resources/articles/dip.pdf