I agree with Mr Yossu.
I am saying nothing new compared to what Mr Yossu said - I am just attaching a skeleton application to show the implementation of the idea.
I have used the Factory Method
to create the employee system objects each of which has the save()
method. The run time choice for which save()
method to run is taken care of by the Strategy
pattern. This is implemented via the interface IEmpSystem
andthe classes CombinedEmpSystem
The client code (the main()
method in this case) has the only dependency - the state of the system. It is passed on the command line to the application as a string - "C"
(i.e. both Legacy and New) and "N"
for just New
You can replace this command line arg by a config file where you store the indicator "C" as long as the Legacy is running. Once the Legacy is retired, update the config file to store "N" and restart the application.