cf. DIP, IoC


Single Responsibility Principle #


Open/Closed Principle #

software entities … should be open for extension, but closed for modification.

- 열려있다 : 확장이 가능한 상태. (wikipedia) A module will be said to be open if it is still available for extension. For example, it should be possible to add fields to the data structures it contains, or new elements to the set of functions it performs. - 닫혀있다 : 다른 모듈에 의해 사용가능한 상태. 잘 정의되고 안정적인 디스크립션(interface)을 가지고 있다. (wikipeda) A module will be said to be closed if it is available for use by other modules. This assumes that the module has been given a well-defined, stable description (the interface in the sense of information hiding).3

ex. JDBC driver : 새로운 구현을 추가하기 쉽다.(열려있다) 추상화된 JDBC API가 정의되어 있다.(닫혀있다)


Liskov Substitution Principle #


Interface Segregation Principle #


Dependency Inversion Principle #

- 고수준 모듈은 저수준모듈에 의존적이지 않아야 한다. 둘 다 추상화된것에 의존해야한다. (wikipedia)High-level modules should not depend on low-level modules. Both should depend on abstractions. - 추상화된것은 상세에 의존적이지 않아야 한다. 상세는 추상에 의존해야한다. (wikipedia)Abstractions should not depend on details. Details should depend on abstractions.

ex.
SmtpMailSender implement MailSender
가 있다면 MailSender를 사용
MailSender 고수준 SmtpMailSender 저수준


ArrayList list = new ArrayList();
보다는
List list = new ArrayList();
를
List 고수준 ArrayList 저수준

Calculator가 있다. 그 부속 기능으로 AdderImpl가 있다. Calculator는 고수준 모듈 AdderImpl는 저수준 모듈 그러므로 Calculator가 AdderImpl을 직접 보지 말고
AdderImpl implements Adder
로 추상화 한 후 Adder를 보도록 함

IoC 와는 어떤 관계?
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-08-16 13:53:53
Processing time 0.0094 sec