[fpc-pascal] about interface and multiple inheritance
mailinglists at geldenhuys.co.uk
Thu Feb 26 15:29:09 CET 2015
On 2015-02-26 13:48, Michael Schnell wrote:
> Neither "COM" nor "CORBA" is something that is imposed by the language,
> but it's features are due to some external framework.
I think you miss understood CORBA interfaces. I don’t know why it was
named as such in FPC, but it definitely doesn’t require or depend on an
external framework or services etc. CORBA interfaces are simply
interfaces (language feature) without reference counting (the latter
being a Windows COM requirement).
> While "interface" (as discussed in this thread) is a language feature
> that somehow extends the "class" paradigm.
Yes, and a very useful (advanced) language feature. To quote Eric Gamma
― “program to an interface, not an implementation”. This has huge
advantages in Object-Oriented Design:
- improves dependency relationships, by reducing them.
- using interfaces means the implementation of the interface
behaviour can change without other code needing to change.
- You can easily mix-in new behaviours to an exiting class. No
error-prone multiple inheritance required.
- a lot more code reuse because of interface delegation.
- reducing complexity. Small classes can each implement a
specific interface. Keeps the class single goal oriented. These
classes can then be reused as interface delegates.
- you can query an object to see if it supports an interface, and
if so get the interface reference which you can use. Not so easy
or clean with inheritance only.
- interface methods can be implemented as private visibility, and
it still allows you to use that interface.
I'm sure given more time I can come up with quite a few more benefits,
but the above is a quick “off the top of my head” list.
Many don’t full understand interfaces (language feature) because, as I
mentioned, it is a slightly more advanced language feature. It also
requires more knowledge of OOP and OOD.
- Graeme -
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
More information about the fpc-pascal