:: Re: [DNG] Experiencing with GtkBuil…
Top Page
Delete this message
Reply to this message
Author: Steve Litt
Date:  
To: dng
Subject: Re: [DNG] Experiencing with GtkBuilder
On Sun, 22 Nov 2015 13:13:47 +0000
Rainer Weikusat <rainerweikusat@???> wrote:

> Edward Bartolo <edbarx@???> writes:
> > Is it possible to use classes and objects while using gtk2/3? I
> > noticed that only functions are used and that class use is ovoided
> > by prepending functions with a group string. As far as I know, C can
> > still use structs that are attached to a set of data and a set of
> > functions, but without inheritance and polymorphyism.
>
> C structs can be embedded into each other which means they can
> 'inherit' other structs, eg, for a totally contrived example
>
> struct something {
>     int number0, number1;
> };

>
> struct another {
>     struct something parent;
>         int drei;
> };


That's composition, not inheritance. It's "has-a", not "is-a". You need
to name the whole chain when calling an element (someth->anoth->drei
rather than someth->drei).

If Edward's anything like me, we both learned OOP from that Philippe
Kahn video where Philippe plays a horn and speaks of these three
capabilities of objects:

* Encapsulation
* Inheritance
* Polymorphism

In my personal opinion, Encapsulation is by far the strongest benefit,
and in fact I seldom use inheritance and almost never use polymorphism.
So personally, I'm just fine with composing large objects with smaller
component objects, all the way down the tree. Especially since a lot of
that nesting can be hidden in methods (I'm pretty sure that function
pointers can be used as methods in C).

But technically, what you wrote above isn't inheritance.

SteveT

Steve Litt 
November 2015 featured book: Troubleshooting Techniques
     of the Successful Technologist
http://www.troubleshooters.com/techniques