Stay Hungry,Stay Foolish!

Principles of Object Oriented Class Design

Principles of Object Oriented Class Design

https://staff.cs.utu.fi/~jounsmed/doos_06/material/DesignPrinciplesAndPatterns.pdf

The Open Closed Principle (OCP)1
A module should be open for extension but closed for modification.
Of all the principles of object oriented design, this is the most important. It originated
from the work of Bertrand Meyer2. It means simply this: We should write our mod-
ules so that they can be extended, without requiring them to be modified. In other
words, we want to be able to change what the modules do, without changing the
source code of the modules.

 

The Liskov Substitution Principle (LSP)1
Subclasses should be substitutable for their base classes.
This principle was coined by Barbar Liskov2 in her work regarding data abstraction
and type theory. It also derives from the concept of Design by Contract (DBC) by
Bertrand Meyer3.

 

The Dependency Inversion Principle (DIP)1
Depend upon Abstractions. Do not depend upon concretions.
If the OCP states the goal of OO architecture, the DIP states the primary mechanism.
Dependency Inversion is the strategy of depending upon interfaces or abstract func-
tions and classes, rather than upon concrete functions and classes. This principle is the
enabling force behind component design, COM, CORBA, EJB, etc.

 

The Interface Segregation Principle (ISP)2
Many client specific interfaces are better than one general purpose interface
The ISP is another one of the enabling technologies supporting component substrates
such as COM. Without it, components and classes would be much less useful and por-
table.

 

Robert C. Martin

http://cleancoder.com/files/about.md

Robert C. Martin

(Uncle Bob)

Mr. Martin has been a programmer since 1970.

He is a co-founder of cleancoders.com, offering on-line video training for software developers.

He is the founder of Uncle Bob Consulting LLC, offering software consulting, training, and skill development services to major corporations worldwide. He served as the Master Craftsman at 8th Light inc, a Chicago based Software Consulting firm.

Mr. Martin has published dozens of articles in various trade journals, and is a regular speaker at international conferences and trade shows.

He is also the creator of the acclaimed educational Clean Code video series at cleancoders.com.

Mr. Martin has authored and edited many books including:

  • Designing Object Oriented C++ Applications using the Booch Method
  • Patterns Languages of Program Design 3
  • More C++ Gems
  • Extreme Programming in Practice
  • Agile Software Development: Principles, Patterns, and Practices.
  • Agile Principles, Patterns, and Practices in C#
  • UML for Java Programmers
  • Clean Code
  • The Clean Coder
  • Clean Architecture

A leader in the industry of software development, Mr. Martin served three years as the editor-in-chief of the C++ Report, and he served as the first chairman of the Agile Alliance.

http://www.tup.tsinghua.edu.cn/booksCenter/book_08196801.html

罗伯特·C.马丁(Robert C. Martin)

业内人士尊称的 “鲍勃大叔”(Uncle Bob),是国际知名的软件工程师和导师,一位有五十多年健康编码经验的程序员。cleancoders.com联合创始人和Uncle Bob咨询公司创始人,主要提供软件咨询、技能培训和视频教学服务。他在专业技术领域具有较深的造诣。除了担任C++ Report杂志的总编辑,他还发表了大量有影响力的文章,受邀在许多国际性软件大会上发表演讲。他是SOLID五大原则的奠基人,是《敏捷宣言》联合签署人并担任过敏捷联盟第一届主席。他擅长的主题有软件匠艺、敏捷软件开发和测试驱动开发等。马丁是个终生学习者,52年出生的他,还在学习飞行驾驶员。

 

第8 章 单一职责原则(SRP) 121

第9 章 开放- 关闭原则(OCP) 127

第10 章 里氏替换原则(LSP) 141

第11 章 依赖倒置原则(DIP) 161

第12 章 接口隔离原则(ISP) 171

Code Example

https://github.com/unclebob/PPP/tree/master

 

posted @ 2024-04-21 22:52  lightsong  阅读(1)  评论(0编辑  收藏  举报
Life Is Short, We Need Ship To Travel