Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any Videos/Screen casts or other resources on how to use Interfaces in Delphi?

Tags:

delphi

Hi are there any nice videos or other resources on how to use Interfaces in delphi?

I am after the basics and more advanced stuff.

like image 302
Charles Faiga Avatar asked Jan 12 '09 14:01

Charles Faiga


3 Answers

Once you have read stuff on the web you should probably look into code by other programmers to see how (and why) they used interfaces in real code.

For example in the Subversion repository of the dUnit SourceForge site you will find the XPObserver.pas file, which implements the Observer pattern for Delphi, using interfaces. This code is very interesting, as usually in this pattern the observed objects each keep a list of observers, and the observers each keep a reference to the object(s) they observe. A naive implementation using interfaces would create circular references, the interfaces would keep their reference counts from reaching 0, and this would result in memory leaks. The code in XPObserver.pas shows how you can use typecasting to solve this problem.

IMO the most of XP*.pas files are worth a closer look. For example XPInterfacedObject.pas contains an explanation why aggregated interfaces must all use a common reference counter, and presents an alternative solution to TAggregatedObject and TContainedObject as implemented in the VCL.

like image 195
mghie Avatar answered Nov 15 '22 06:11

mghie


Not a video, but this explains the basics.

like image 44
Toon Krijthe Avatar answered Nov 15 '22 07:11

Toon Krijthe


Since COM uses interfaces this online course is also an introduction to interfaces.

like image 40
Lars Truijens Avatar answered Nov 15 '22 06:11

Lars Truijens