I have 3 different DataModules: ADOModule, SDACModule, AstaModule. All are identical, except DB components they use: ADO, SDAC, Asta.
All these DataModules do the same job, but through the different components. What I mean - is that all inner selects and execs are the same.
What I search for: is a method to combine all of this DataModules to one BaseDataModule, and force each of ADOModule, SDACModule and AstaModule to inherit from BaseDataModule.
Well, I find it easy to inherit methods and properties, but I've never used to inherit from components. Is there any nice way to do so? Project goal: minimize coding and copy-pasting.
There are several options available to you but the approach I would take would be as follows :-
Create an abstract base class for your Database and Query components. Your base class should define all the methods and properties you're going to need.
Create concrete descendants for each data access layer that are effectively wrappers around the underlying data-access layer.
Move the current data module code into a non-visual unit that references the abstract component type instead of any specific type of access layer.
You can now easily switch between access layers or even add new ones in the future.
This is a classic example of the Adapter (or Wrapper) pattern.
If you'd rather not re-invent the wheel, you might want to consider looking at an OPF/ORM solution like tiOPF, InstantObjects or TMS Aurelius which will give you the same functionality and a lot more besides.