1. Technology

Your suggestion is on its way!

An email with a link to:

http://delphi.about.com/u/ua/oopindelphi/interface-your-delphi-buggyman.htm

was emailed to:

Thanks for sharing About.com with others!

Readers Respond: Have you implemented any Interfaces lately? Why, what for?

Responses: 5

By

Most Delphi developers when they think of interfaces they think of COM programming. However, interfaces are just an OOP feature of the language - they are not tied to COM specifically. Interfaces can be defined and implemented in a Delphi application without touching COM at all.

Have you ever created (and implemented) your own interface? Why?

Share with us some real-world examples in using interfaces in Delphi applications...

Use interface to restrict MDI app

define a mdi child form implement a interface, to execute some common features. and use a interface to restrict two main form: one for test, another for the actual.
—cablefan

Using Interfaces

I use interfaces as an easy way to access objects and data in an external DLL. Great way for creating plugins and system extentions without having to re issue a full system release. Albiet the implementations can be quite big (code wise) but still alot more structured way to modularise my code and systems.
—Guest Brendan McLaughlin

Adding functionality to existing classes

Interfaces are a nice way of asking if an object "supports some functionality". We could do this by using "is" (eg: "if obj is TWinControl") but this requires objects to fall within a certain class hierarchy implementing the required functionality. I use interfaces for a design application where objects need functionality like printing. If I rely on class hierarchy to determine if objects support common functionality then I have to either a) re-create an entire control class hierarchy (buttons, edits, labels, memos etc) that include a base class with the common functionality or b) implement the common functionality in a non-OOP if-then-else construct. With interfaces, I can derive new classes directly from existing classes (I don't have to re-write my own versions of TLabel, TEdit, TMemo etc) and simply implement the new interfaces. To see if a control has the functionality we simply ask if the object "supports" the interface.
—Guest Etherman

Why do I use interfaces

I use interfaces to share methods and properties in classes that do not inherit from the same parents. For instance to create a set of data-aware controls having common methods like Load, Save, AsText, ...
—Guest Pascal Piret

Interfaces sounded too complex for me...

But after reading this article ... I see dozens of places in my applications where interfaces will come handy. Thanks!
—rascal1936

©2014 About.com. All rights reserved.