[fpc-pascal] implements
Sven Barth
pascaldragon at googlemail.com
Sat Sep 2 13:56:50 CEST 2017
Am 02.09.2017 10:38 schrieb "Ryan Joseph" <ryan at thealchemistguild.com>:
>
>
> > On Sep 2, 2017, at 3:27 PM, Graeme Geldenhuys <
mailinglists at geldenhuys.co.uk> wrote:
> >
> > Please search the internet about Interfaces and probably Design
Patterns too. Have ever heard the phrase: "Code to an Interface, not an
Implementation".
> >
> > Interfaces are so much more than simply "adding methods to a class".
>
> I understand interfaces just fine but I don’t understand why you want a
class to appear as if it implements an interface but then having to call
methods on a 2nd class. It separates the code (which is nice) but then
gives you an annoying extra step of typing hook.XXX for every method. It
just feels broken and not complete as a feature.
>
> Furthermore if you know that a class implements an interface but you need
to call another variable (like hook) then how do you know the name of the
variable??? I use interfaces often but that would break them for me in most
cases.
As Graeme said: the point is to code against interfaces, not classes. Don't
pass around or work with the TBaseClass instance, instead only with the
IHook interface. And this is what the implements feature is for.
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170902/5f31a078/attachment.html>
More information about the fpc-pascal
mailing list