Using Delphi XE2, I'm wondering if it would be usable to define a base object something like below. Class is prone to be used in multiple projects.
I've chosen TSQLConnection as my starting point - since it's using the dbxpress framework and should be able to connect to a wide range of databases and other. But if a better solution exists - please feel free to comment on this.
TMyObject = class
private
fConnection : TSQLConnection;
public
procedure SetupConnection(aConn : TSQLConnection);
property Connection : TSQLConnection read fConnection write fConnection;
... // a lot of other properties and methods ...
end;
procedure TMyObject.SetupConnection(aConn : TSQLConnection);
begin
fConnection := aConn; // Should we clone here? ... or is a reuse ok?
end;
This way it would be possible to use a connection from any of my inherited classes.
Questions:
- Is this a good design? (from a general point of view)
- Is the use of
TSQLConnection
OK, if we have like 200 inherited instances? - Making the assignment of the
Connection
- is it ok to re-use from the datamodule? - Perhaps the
SQLConnection
was better located in anInterface
?
Intentions
My intention is to create a "base class structure" for all my classes (in all my projects), and make it easier for co-workers to develop new applications, based on this hierarchy.