The primary mechanisms behind the Open-Closed principle are abstraction and polymorphism.
In statically typed languages like C++, one of the key mechanisms that supports
abstraction and polymorphism is inheritance. It is by using inheritance that we can
create derived classes that conform to the abstract polymorphic interfaces defined by pure
virtual functions in abstract base classes.

 inheritance를 이용하여 객체지향의 특성(polymorphism, abstraction)을 활용한다.

What are the design rules that govern this particular use of inheritance? What are the
characteristics of the best inheritance hierarchies? What are the traps that will cause us to
create hierarchies that do not conform to the Open-Closed principle? These are the questions
that this article will address.

상속의 사용에 있어 설계의 원칙이 있는가?
상속을 이용한 디자인의 특성은 무엇인가?

FUNCTIONS THAT USE POINTERS OR REFERENCES TO BASE
CLASSES MUST BE ABLE TO USE OBJECTS OF DERIVED CLASSES
WITHOUT KNOWING IT.

Reference 형을를 쓰는 기능은 상속되는 클래스는 실제 Object의 구조를 알 필요없이,
상위 레벨의 클래스의 Object로 사용될 수 있어야 한다.

The above is a paraphrase of the Liskov Substitution Principle (LSP). Barbara Liskov first
wrote it as follows nearly 8 years ago1:

위의 문장은 LSP 정의의 의역이고 바바라 리스코프는 처음에 다음과 같이 섰다.(8년전)

What is wanted here is something like the following substitution property: If
for each object o1 of type S there is an object o2 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.

복잡하다.. -_-;


The Open-Closed principle is at the heart of many of the claims made for OOD. It is when
this principle is in effect that applications are more maintainable, reusable and robust. The
Liskov Substitution Principle (A.K.A Design by Contract) is an important feature of all
programs that conform to the Open-Closed principle. It is only when derived types are
completely substitutable for their base types that functions which use those base types can
be reused with impunity, and the derived types can be changed with impunity.

상위 class의 객체를 상속구조상의 하위 class의 객체로 대체할수 있어야 된다..
OCP 를 더욱 견고히 하기위한 원칙..



+ Recent posts