是否有有关如何在Delphi中使用界面的视频/屏幕截图或其他资源? [英] Are there any Videos/Screen casts or other resources on how to use Interfaces in Delphi?

查看:102
本文介绍了是否有有关如何在Delphi中使用界面的视频/屏幕截图或其他资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于在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.

推荐答案

一旦您在网络上阅读了一些东西,您可能应该研究其他程序员的代码,以了解他们如何(以及为什么)在真实代码。

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.

例如在 dUnit SourceForge网站的Subversion存储库,您会找到 XPObserver.pas 文件,该文件使用接口为De​​lphi实现了Observer模式。这段代码非常有趣,因为通常在这种模式下,观察到的对象每个都会保留一个观察者列表,并且观察者每个都保留对其观察到的对象的引用。使用接口的幼稚实现将创建循环引用,接口将使它们的引用计数保持为0,这将导致内存泄漏。 XPObserver.pas中的代码显示了如何使用类型转换来解决此问题。

For example in the Subversion repository of the dUnit SourceForge site you will find the XPObserver.pas file, which implements the Observer pattern for Delp 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大部分XP * .pas文件值得一看。例如, XPInterfacedObject。 pas 解释了为什么聚合的接口都必须全部使用一个公共的引用计数器,并提供了Vgl中实现的TAggregatedObject和TContainedObject的替代解决方案。

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.

这篇关于是否有有关如何在Delphi中使用界面的视频/屏幕截图或其他资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆