What are the pros and cons of using interfaces in Delphi?

前端 未结 9 1582
既然无缘
既然无缘 2021-01-31 17:21

I have used Delphi classes for a while now but never really got into using interfaces. I already have read a bit about them but want to learn more.

I would like to hear

9条回答
  •  佛祖请我去吃肉
    2021-01-31 18:17

    Beyond what others already listed, a big pro of interfaces is the ability of aggregating them.

    I wrote a blog post on that topic a while ago which can be found here: http://www.nexusdb.com/support/index.php?q=intf-aggregation (tl;dr: you can have multiple objects each implementing an interface and then assemble them into an aggregate which to the outside world looks like a single object implementing all these interfaces)

    You might also want to have a look at the "Interface Fundamentals" and "Advanced Interface Usage and Patterns" posts linked there.

提交回复
热议问题