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
相关文章
- 01-07how to avoid inheritance abuse
- 01-07How to avoid decoding to str: need a bytes-like object error in pandas?
- 01-07Too Many Connections: How to Increase the MySQL Connection Count To Avoid This Problem
- 01-07Oracle JDBC prefetch: how to avoid running out of RAM
- 01-07[转载]How to avoid using() mistake in C#?
- 01-07How to detect and avoid memory and resources leaks in .NET applications