Building data-driven user interface
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 for the database will be simple. Drop the TTabControl
component on the form, align it to Client
, and rename to tbctrlMain...