how to avoid inheritance abuse

Liskov Principle: if S is a subtype of Type T, then any objects of type T may be repalced by objects of type S without altering any of the properties of T;
that is, if B inherits from A, then B should be a A!!!
usaully we adopt inheritance for two reason:
1) interface (for polymorphism)
2) implementation (for code reuse)
if it's for implementtation, coposition is good enough for it;
as used in most design patten, we commenly use two layers of inheritance, interface and its implementation.
with good design, we seldom more than 3 or 4 layers

上一篇:zabbix 3.4监控mysql,提示mysql: [Warning] Using a password on the command line interface can be insecure.


下一篇:【原创】python内存泄漏以及python flask框架莫名coredump