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

后端 未结 3 1650
迷失自我
迷失自我 2021-02-06 10:35

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.

相关标签:
3条回答
  • 2021-02-06 10:59

    Not a video, but this explains the basics.

    0 讨论(0)
  • 2021-02-06 11:02

    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.

    0 讨论(0)
  • 2021-02-06 11:12

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

    0 讨论(0)
提交回复
热议问题