Final answer:
To make DataViz configurable at runtime to use SuperStats or UberStats, implement the abstract factory design pattern. Create an abstract class called StatsFactory with two concrete subclasses. Set the desired factory at runtime in DataViz. This design allows for easy switching between the two libraries.
Step-by-step explanation:
To redesign the DataViz class to be configurable at runtime to use either SuperStats or UberStats, you can implement the abstract factory design pattern. This pattern allows you to create families of related objects without specifying their concrete classes.
In this case, you can create an abstract class called StatsFactory, which will have two concrete subclasses: SuperStatsFactory and UberStatsFactory. Each factory will provide implementations for the functions in their respective libraries/classes.
DataViz will have a member variable of type StatsFactory, which will be set to either SuperStatsFactory or UberStatsFactory at runtime based on the desired configuration.
The functions in DataViz can then call the functions from the StatsFactory, without needing to know which specific library/class is being used. This design allows for easy switching between SuperStats and UberStats without modifying the code in DataViz.