B
B
BonBon Slick2018-07-16 20:23:46
Software design
BonBon Slick, 2018-07-16 20:23:46

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

1 answer(s)
M
Maxim Fedorov, 2018-07-16
@BonBonSlick

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 question

Ask a Question

731 491 924 answers to any question