Answer the question
In order to leave comments, you need to log in
Which pattern to choose?
There is a package, the package has a class, Stopwatch, it does not implement any interface. It is necessary to inject it in certain places in order to monitor the load, but there is no interface, and it is harmful to inject the implementation, we lose abstraction.
What pattern is suitable in such cases?
When you need to inject a class from vendor that comes without an interface.
Answer the question
In order to leave comments, you need to log in
Make a decorator over this class, the decorator has an interface and inject it.
You are many times more experienced than me, why didn’t it come to you at the click of a finger?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question