0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SOLIDについて

Last updated at Posted at 2020-11-05

SOLIDって?

OODの設計で心がけること。
以下、SOLIDってつまりこういうことでしょって自己解釈。

Single Responsibility

1クラス、1つの役割、多すぎると抽象化しにくい。

Open Close

他の原則を守ればなされる

  • 拡張に開いている

    インタフェース、抽象クラスを実装した新しいクラスで機能を追加できる。

  • 修正に閉じている

    インタフェース、抽象クラスを実装しているので修正しにくい。

Liskov Substitution

基底クラス型でインスタンスを扱う。
派生クラスで好き勝手しない(ふるまいを変えない)、いわゆるIsA関係に従う。

Interface Segregation

実装クラスで扱わないメソッドはインタフェースで定義しない。
というよりは、インタフェースに機能が多すぎる、SRPに従う。

Dependency Inversion

抽象に依存する
インタフェース、抽象クラスは積極的に使う(正しく)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?