Suppose you are developing a data visualization application DataViz which calls some functions from a statistics library class SuperStats. You recently heard about another statistics library UberStats with supposedly significantly better performance than SuperStats. Explain how you would redesign the DataViz class using the Adapter pattern so that DataViz can be configured at runtime to use either SuperStats or UberStats. Does your design use dependency inversion and/or dependency injection? Explain

Respuesta :

Answer:

By using dependency injection, create the adapter to adapt both the DataViz and the UberStats interface as expected.

Explanation:

Adapters are used in Objected-oriented programming to run or convert the output of one class object to another. The DataViz class currently uses the SuperStats class as an adaptee to get and output statistical results.

Write a new code from the scratch is tedious, so, the UberStats class dependencies are injected in the adapter and the DataViz and UberStats class functionalities can be experimented with.