POV-Ray : Newsgroups : povray.off-topic : Lots of statistics : Re: C# Server Time
29 Jul 2024 10:27:58 EDT (-0400)
  Re: C#  
From: Warp
Date: 14 Aug 2012 07:00:32
Message: <502a2fd0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 13.08.2012 19:26, schrieb Warp:

> >> Yeah, I don't know. I'm slowly coming around to the idea that maybe we
> >> should forget about all this "inheritance" stuff and focus on interfaces
> >> as the primary thing of interest...
> >
> > How would you implement a GUI library without using any kind of inheritance?

> By using /interfaces/ maybe?

Given that interfaces cannot contain member variables nor function
implementations (at least not in any language I know of), it would make
the GUI library *really* annoying to use because of all the required code
repetition. (For example, every time the library needs to know the
coordinates of the object on screen, it would have to call a function
declared in the interface, which the user would have to implement in his
own code to return those coordinates. It would also cripple any possibility
of using eg. a screen element that contains other screen elements, because
such an object would just be an interface and cannot contain anything.)

> You can argue that a class that implements an interface effectively 
> "inherits" from it, but you can also argue against it. It's a matter of 
> how exactly you define "inheritance".

Inheritance implements the OO concept of an "is-a" relationship. If a class
implements an interface, then it effectively has an "is-a" relationship to
it. (For example, if the interface is named, let's say, ButtonListener,
and you implement it, then your class "is-a" ButtonListener. You can give
an object of your class to anything that expects a ButtonListener. It doesn't
get any more straightforward and clear inheritance than that.)

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.