Suppose there is a class that writes its state to the disk, and loads it back during initialization. It is logical to do this in the constructor. But in terms of unit tests, this is crooked. If I put it into the initialize method, then I oblige the external code to pull it too, then it produces different statuses initializing and so on.
Do I understand correctly that a good design will be the following:
- some kind of factory that is responsible for creating and initializing a class
- LastStateInfo object
- an additional constructor is added to the class that accepts LastStateInfo
Are there any typical approaches? How it's called? How can you google it?