객체와 관계를 이용한 실세계 매핑
관계 유형
Aggregation / Composition
Inheritance / Realization
Dependency
상황(Context)에 따라 관계 유형이 달라짐
LSP (Liskov Substution Principle) (WIKIPEDIA : Liskov substitution principle)
-. 기존 타입의 하위 타입을 만드는 가이드
-. Substitutabllity (대체 가능성)
"if S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substituted for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.)"
-. Barbara Liskov
"What is wanted here is something like the following substitution property: If for each object o1 of type S there is an object 02 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T."
S타입의 객체 o1에 대해 T타입의 객체 o2가 있을 경우, T로 정의된 모든 프로그램 P에 대해, o1이 o2로 대체되어도 P가 변경되지 않는다면 S가 T의 하위타입니다.
-. 프로그램 모듈이 Base클래스에 대한 참조를 사용하고 있다면, 프로그램 모듈의 기능에 영향을 주지 않고 Base 클래스를 파생클래스로 대체할 수 있다.
WIKIPEDIA : Liskov substitution principle
아직 남아있다.
'Patterns' 카테고리의 다른 글
Template Method - 하위 클래스에서 구체적으로 처리하기 (0) | 2013.05.06 |
---|---|
Abstract Factory - 관련 부품을 조합해서 제품만들기 (0) | 2013.05.06 |
Singleton - 인스턴스를 한 개만 만들기 (0) | 2013.05.04 |
01. 객체-지향(Object-Oriented) 개념 (0) | 2013.05.04 |
Prototype 패턴 - 복사해서 인스턴스 만들기 (0) | 2013.05.03 |