SOLID Principles of Object-Oriented Programming


In object-oriented computer programming, SOLID is a mnemonic acronym for five design principles intended to make software designs more understandable, flexible and maintainable. It is not related to the GRASP software design principles.

Quoting from SOLID – wiki

S – O – L – I – D

S – Single Responsibility Principle

A class should only have a single responsibility, that is, only changes to one part of the software’s specification should be able to affect the specification of the class.

O – Open–Closed Principle

In object-oriented programming, the open/closed principle states “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification“; that is, such an entity can allow its behaviour to be extended without modifying its source code.

在面向对象编程中, 开放封闭原则的核心思想是”软件实体应该是可扩展, 而不可修改. 也就是说, 对扩展是开放的,而对修改是封闭的.”

Quoting from Open-Closed Principle – wikipedia

开放/封闭原则(Open-Closed principle)是面向对象设计的基本原则之一(SOLID中的O) ,声明一个软件实体应该对扩展是开放的, 对修改则是封闭的。


L – Liskov Substitution Principle

“Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.” See also design by contract.

I – Interface Segregation Principle

“Many client-specific interfaces are better than one general-purpose interface.”

D – Dependency inversion principle


SOLID – wikipedia
Single Responsibility Principle – wikipedia
Open-Closed Principle – wikipedia
Liskov Substitution Principle – wikipedia
Interface Segregation Principle – wikipedia
Dependency inversion principle – wikipedia