One of the best ways to drive different behavior in the application is to instantiate different implementations of an interface. The code using the instantiated object only knows the interface which remains constant, but the behavior is determined by the actual object instance.
A Database connection interface may have a
connect() method, implemented by different database drivers.
To support this, we can have a parallel config structure:
With this, you can instantiate the object from the configuration with a single line of code:
MySQL is the default per the
Change the instantiated object class and override values from the command line: