Link to Gordian's home page The Black Sea of Technology
Link to New TechnologyLink to White Papers


White Papers - Articles

"Creating Synergistic Components with Delphi"

James Callan - KOG Webzine (Page 3)

Aggregated Awareness
Building up complex applications from simpler components is what makes component-based development attractive. Aggregation makes this possible. When constructing components that use other components developers must consider two forms of aggregation, also known as "has relationships" between related classes. Aggregation can be "by value" or "by reference," and either may or may not involve actual physical containment of one class inside another.

For example, in Delphi you lay out forms by aggregating various controls. When you examine a form's class definition you find that each control that you placed on your form has a corresponding definition within the form. Similarly, if you define a new component that "has" an integer property, you will define a variable of type integer in which to store the value. This is containment "by value."

By contrast, aggregation "by reference" involves, in Delphi, defining a property in one component that refers to another component, whose services the designed component uses. The TDataSource component makes use of "by reference to" a TTable component via the DataSet property. If you have ever defined your own data aware components, you will recall that your component had to respond to notification messages in order to avoid using a "bent pointer" when your TTable component was deleted. In this fashion, the DataSource's DataSet property contains the TTable component by reference. Notice that "by reference" use can often be more powerful than "by value" use because related components, like the TTable, can serve other components in addition to the TDataSource component.

Previous PageNext Page

Signature Block of Gordian Solutions