Discussion:
Linking Components
(too old to reply)
Jeffrey A. Wormsley
2004-01-23 21:38:17 UTC
Permalink
I'd like to make a set of components that act like the Dataset and DB aware
controls. These would all be non-visual components. The idea is that
there is one "base component", one or more "next level" components that use
the base component all at the same time, and then one or more "top level"
components that can use one and only one "next level" components.
Something like this:

Base Component
|
/------------|-------------\
Next Level Next Level Next Level
| | |
Top Level Top Level Top Level

Think of it like this. The "base component" is a table, the "next level"
is a dataset, and thr "top level" is a DBEdit, only each DBEdit component
would have to have its own dataset to connect to the table, rather than
through a common one.

My question is, how would I go about implementing such a thing? Especially
with the requirement that the base component should fire events when
something happens to a top level component.

Or is this too confusing?

Jeff.
Robert Marquardt
2004-01-24 07:05:40 UTC
Permalink
Post by Jeffrey A. Wormsley
I'd like to make a set of components that act like the Dataset and DB aware
controls. These would all be non-visual components. The idea is that
there is one "base component", one or more "next level" components that use
the base component all at the same time, and then one or more "top level"
components that can use one and only one "next level" components.
Base Component
|
/------------|-------------\
Next Level Next Level Next Level
| | |
Top Level Top Level Top Level
Think of it like this. The "base component" is a table, the "next level"
is a dataset, and thr "top level" is a DBEdit, only each DBEdit component
would have to have its own dataset to connect to the table, rather than
through a common one.
My question is, how would I go about implementing such a thing? Especially
with the requirement that the base component should fire events when
something happens to a top level component.
Or is this too confusing?
Jeff.
This is a classic abstract design, but it is wrong here.
The problem is that you do not have polymorphism in Delphi.
You will need several trees of components.

A TDBEdit has to descend from TEdit whereas a TTable not.

A TDBEdit is therefore linked by a property to the TTable it needs.
This is the design of the VCL.

The classic design for the base component is to have all methods and
properties as protected so only the descendants have access. The
descendants make them public or published as needed.
The name of such a base component should contain Custom.
Ideally the first descendant sould only publish the metds and
properties. Nothing else.
R. Vermeij
2004-01-26 08:55:50 UTC
Permalink
Search for the Design Pattern named 'Observer'. Maybe that will help you.
Loading...