The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,803 other followers

Delphi: do not mix interfaces and classes part X

Posted by jpluimers on 2018/03/15

A very interesting discussion on what the mixing of interfaces and classes can get you into: [WayBack] I’ve got an interface with generics which accepts classes:IMyGeneric = interface…..end;What I want to do is to allow this interface to… – John Kouraklis – Google+

TL;DR: do not mix interfaces and classes.

As often, Asbjørn Heid chimes in showing some insight on clever mixing of the two with sample code accepting an unconstrained type. Don’t do that unless you really know what’s going on behind the scenes.




4 Responses to “Delphi: do not mix interfaces and classes part X”

  1. thaddy said

    Note this only applies to COM interfaces and not to CORBA. The latter being not reference counted anyway.

  2. jpluimers said

    In a share of that thread at [WayBack, Dalija Prasnikar mentions:

    Reference counted object instances must have at least one strong reference to keep them alive. Interface reference represents such strong reference. Object reference acts like weak one.

  3. jpluimers said

    Chee Wee Chua mention on the G+ thread [WayBack] that he blogged about this as well:

    [WayBack]Something to ponder: using interfaces with class type variables

    I think this is related to what he writes: Should the compiler hint/warn when passing object instances directly as const interface parameters? [WayBack]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: