|
|
|
|
|
by ckdot2
1030 days ago
|
|
Don't re-use using inheritance, but dependency injection.
A (well-tested) software component that get's dependency-injected should get considered "final". If it makes sense to adjust it, you may still can do it - there's nothing preventing you from this. But you should always be aware that logic relying on the dependency may behave different in a way you haven't forseen. If you just want to make a change for a single place in your software, you can easily replace the dependency with another one implementing the same interface. You could even decorate the original dependency if you want to re-use most of it's code.
What I want to say, nearly all of the abstraction issues come from inheritance and in many, many cases there's no need to use inheritance at all. |
|