2 ms·
...and the corollary to that is turning things into data is often a much simpler alternative to abstraction. For example suppose you have a program with config
by phaedrus 5y ago
...and the corollary to that is turning things into data is often a much simpler alternative to abstraction.
For example suppose you have a program with configuration. You might have a "ConfigurationProvider" and abstract that with an "IConfigurationProvider" and mock implementations of that interface for unit tests.
Or you could simply define a Plain Old Data structure with fields for the configuration data. Then you can construct an instance of that data structure in different ways as appropriate.
The key idea there is: "data" is something that's already automatically decoupled from where the data came from. For code you have to do work to achieve that decoupling, and it will always leak.