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

前端 未结 9 1558
既然无缘
既然无缘 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 17:56

    Adding to the answers few more advantages:

    1. Use interfaces to represent the behavior and each implementation of a behavior will implement the interface.
    2. API Publishing: Interfaces are great to use when publishing APIs. You can publishing an interface without giving out the actual implementation. So you are free to make internal structural changes without causing any problems to the clients.

提交回复
热议问题