👏

SOLID原則(オブジェクト指向の基本原則[基本5原則]), 開放閉鎖の原則(OCP)

2024/12/29に公開

SOLID原則(オブジェクト指向の基本原則[基本5原則])

"SOLID原則"とは、以下の5つの原則の頭文字を並べて出来たネーミング。
オブジェクト指向の基本原則[基本5原則]。

SOLID 内容 日本語
[SRP] single-responsibility principle There should never be more than one reason for a class to change. 単一責任の原則
[OCP] open/closed principle software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification. 開放閉鎖の原則
[LSP] Liskov substitution principle Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it. リスコフの置換原則
[ISP] interface segregation principle Many client-specific interfaces are better than one general-purpose interface. インターフェース分離の原則
[DIP] dependency inversion principle High-level modules should not import anything from low-level modules. Both should depend on abstractions (e.g., interfaces), [not] concretions. 依存性逆転の原則

Discussion