オブジェクト指向設計の原則 概要
2008/07/21 22:04Update
オブジェクト指向設計の原則(Principles Of Object Oriented Design)とは、オブジェクト指向設計(OOD)において、「何をどうしてどうやって進んでいくべきか」というオブジェクト指向設計のルールを規定するものです。
Robert C. Martin氏による有名なオブジェクト指向設計(OOD)の原則“Principles of OOD”があります。
The Open-Closed Principle (OCP) - OO設計のOCP開放/閉鎖原則
Software entities (classes, modules, function, etc.) should be open for extension, but closed for modification.
ソフトウェアエンティティ(クラス、モジュール、関数など)は拡張に対して開放であり、修正に対して閉鎖すべきである。
Single Responsibility Principle (SRP) - OO設計のSRP単一責任原則
There should never be more than one reason for a class to change.
クラスを変更する理由は一つ以上存在してはならない。クラスの責務(役割)は一つでなければならない。
Interface Segregation Principle (ISP) - OO設計のISPインターフェイス分離原則
Clients should not be forced to depend upon interfaces that they do not use.
使用していないインタフェースを依頼してはならない。
Liskov Substitution Principle (LSP) - OO設計のLSP リスコフ置換原則
Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.
基底クラスとして正しく動作する場合、代わりにその派生クラスも正しく動作すべきである。
Dependency Inversion Principle (DIP) - OO設計のDIP依存逆転原則
A. High level modules should not depend upon low level modules. Both should depend upon abstractions.
B. Abstractions should not depend upon details. Details should depend upon abstractions.
上位モジュールは下位モジュールに依存してはならない。両者は抽象に依存すべきである。抽象は詳細(抽象の実装クラス)に依存してはならない。詳細は抽象に依存すべきである。
Release Reuse Equivalency Principle (REP) - OO設計のREP再利用・リリース等価原則
The granule of reuse is the granule of release.
再利用の単位とリリースの単位は等価である
The Common Reuse Principle (CRP) - OO設計のCRP全再利用原則
The classes in a package are reused together. If you reuse one of the classes in a package, you reuse them all.
パッケージに含まれるクラスは、すべて一緒に再利用される
The Common Closure Principle (CCP) - OO設計のCCP閉鎖性共通原則
The classes in a package should be closed together against the same kinds of changes. a change that affects a package affects all the classes in that package.
パッケージに含まれるクラスは、同種類の変更に対して、共に閉じているべきである。パッケージに影響を与えた変更は、パッケージに含まれるすべてのクラスにも影響を与えたと見なす。
The Acyclic Dependencies Principle (ADP) - OO設計のADP非循環依存原則
The dependency structure between packages must be a directed acyclic graph (DAG). That is, there must be no cycles in the dependency structure.
パッケージ間の依存関係は循環してはならない
The Stable Dependencies Principle (SDP) - OO設計のSDP安定依存原則
The dependencies between packages in a design should be in the direction of the stability of the packages. A package should only depend upon packages that are more stable that it is.
パッケージ間の依存は安定する方向に依存すべきである。パッケージは自分より安定したパッケージを依存すべきである。
The Stable Abstractions Principle (SAP) - OO設計のSAP安定度・抽象度等価原則
Packages that are maximally stable should be maximally abstract. Instable packages should be concrete. The abstraction of a package should be in proportion to its stability.
最も安定したパッケージは最も抽象的なパッケージであるべきである、最も不安定なパッケージは最も具体的なパッケージであるべきである。パッケージの抽象度と安定度とは同程度でなければならない。
オブジェクト指向設計の原則 - クラス設計の原則
The Open-Closed Principle (OCP) - OO設計のOCP開放/閉鎖原則Software entities (classes, modules, function, etc.) should be open for extension, but closed for modification.
ソフトウェアエンティティ(クラス、モジュール、関数など)は拡張に対して開放であり、修正に対して閉鎖すべきである。
Single Responsibility Principle (SRP) - OO設計のSRP単一責任原則There should never be more than one reason for a class to change.
クラスを変更する理由は一つ以上存在してはならない。クラスの責務(役割)は一つでなければならない。
Interface Segregation Principle (ISP) - OO設計のISPインターフェイス分離原則Clients should not be forced to depend upon interfaces that they do not use.
使用していないインタフェースを依頼してはならない。
Liskov Substitution Principle (LSP) - OO設計のLSP リスコフ置換原則Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.
基底クラスとして正しく動作する場合、代わりにその派生クラスも正しく動作すべきである。
Dependency Inversion Principle (DIP) - OO設計のDIP依存逆転原則A. High level modules should not depend upon low level modules. Both should depend upon abstractions.
B. Abstractions should not depend upon details. Details should depend upon abstractions.
上位モジュールは下位モジュールに依存してはならない。両者は抽象に依存すべきである。抽象は詳細(抽象の実装クラス)に依存してはならない。詳細は抽象に依存すべきである。
オブジェクト指向設計の原則 - パッケージ設計の原則
パッケージ内の凝集度関連の原則
Release Reuse Equivalency Principle (REP) - OO設計のREP再利用・リリース等価原則The granule of reuse is the granule of release.
再利用の単位とリリースの単位は等価である
The Common Reuse Principle (CRP) - OO設計のCRP全再利用原則The classes in a package are reused together. If you reuse one of the classes in a package, you reuse them all.
パッケージに含まれるクラスは、すべて一緒に再利用される
The Common Closure Principle (CCP) - OO設計のCCP閉鎖性共通原則The classes in a package should be closed together against the same kinds of changes. a change that affects a package affects all the classes in that package.
パッケージに含まれるクラスは、同種類の変更に対して、共に閉じているべきである。パッケージに影響を与えた変更は、パッケージに含まれるすべてのクラスにも影響を与えたと見なす。
パッケージ同士間の結合度関連の原則
The Acyclic Dependencies Principle (ADP) - OO設計のADP非循環依存原則The dependency structure between packages must be a directed acyclic graph (DAG). That is, there must be no cycles in the dependency structure.
パッケージ間の依存関係は循環してはならない
The Stable Dependencies Principle (SDP) - OO設計のSDP安定依存原則The dependencies between packages in a design should be in the direction of the stability of the packages. A package should only depend upon packages that are more stable that it is.
パッケージ間の依存は安定する方向に依存すべきである。パッケージは自分より安定したパッケージを依存すべきである。
The Stable Abstractions Principle (SAP) - OO設計のSAP安定度・抽象度等価原則Packages that are maximally stable should be maximally abstract. Instable packages should be concrete. The abstraction of a package should be in proportion to its stability.
最も安定したパッケージは最も抽象的なパッケージであるべきである、最も不安定なパッケージは最も具体的なパッケージであるべきである。パッケージの抽象度と安定度とは同程度でなければならない。
Sponsored Link
- Relative Articles
- ASP.NETでのフロント・コントローラ(Front Controller)実装 - (2009/10/20 15:22)