The data access logic has been implemented and it is available through the IToDoData interface. This should be the only way for the user interface logic to access the data. That is why we are going to implement the GetToDoData method in the main form's unit that will return the reference to the data access interface. See the following code:
uses uDMToDo; function TFormToDo.GetToDoData: IToDoData; begin if DMToDo = nil then DMToDo := TDMToDo.Create(Application); Result := DMToDo; end;
In this way, we have achieved a truly pluggable architecture. If we decide to change the underlying database access logic, database access framework, or the database platform, we only need to make sure that the new implementation implements the IToDoData interface that is available to the GUI code through the GetToDoData method.
The user interface...