RAD Studio |  |

Reusing Code and Delegation
See Also
Collapse All

One approach to reusing code with interfaces is to have one interfaced object contain, or be contained by another. Using properties that are object types provides an approach to containment and code reuse. To support this design for interfaces, the Delphi language has a keyword implements, that makes if easy to write code to delegate all or part of the implementation of an interface to a subobject.

Aggregation is another way of reusing code through containment and delegation. In aggregation, an outer object uses an inner object that implements interfaces which are exposed only by the outer object.

See Also

Using Interfaces with Procedures

Implementing IInterface

Using the as Operator with Interfaces

Using Interfaces Across the Hierarchy

Memory Management of Interface Objects

Using Interfaces in Distributed Applications

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!