Re: GObject docs improvements



Hi,

Shixin Zeng wrote:
I've read it once more, with the example in David NeÄas (Yeti)'s
email. I think I understand the interfaces a bit more.

But I have some other questions:

1) Is interface the GObject's way to implement multiple inheritance?

To my understanding, interface is a method to share some
resources(data, methods etc.) in different classes, which can be
implemented by inheritance. However, in Gobject system, one class can
only have one base class, if there were no interfaces, one would have
to inherit from the same base class with the class with which he wants
to share some resources, or derived from that class or be that class's
parent class. And sometimes, this method is not straightforward or
convinient, especially for some classes with some very different
implementation but with some same methods(interfaces), I think, this
is where the concept interface helps.

This is unfortunately often mistaken. Interfaces are good if you want to hide
internals behind one and the same interface, but this covers only one aspect.
One example. You have a normal object hierarchy like in Gtk+, then you want to
implement accessibillity features for e.g. blind people (like 'give me a textual
representation of yourself'). That means that some of the object in your
hierarchy need some additional function. If you use an interface, than you can
check if the provide the extra function.

Sometimes its possible to achieve something similar to multiple inheritance by
using the delegate pattern. A will inherit from B, have one instance of C and
provice wrapper calls for C.


2)How its intefaces handled, when a class is derived? Will the child
classes possess the same interfaces, if they don't want to reimplement
them?
Good question. I need to look a bit more into that.

Stefan



Thanks.

On 2/10/07, Stefan Kost <ensonic hora-obscura de> wrote:
Shixin Zeng wrote:
Thanks. But I want some explanation about the interface of gobject. I
can't understand what it is from a sentence like "GType's Interfaces
are very similar to Java's interfaces." because I know nothing about
Java, and I don't want to dig into Java just for this concept.

Yes this was also one on my critics and I changed it to:

GType's Interfaces are very similar to Java's interfaces. They allow
to describe a common API that several classes will adhere to.
Imagine the play, pause and stop buttons on hifi equipment - those can
be seen as a playback interface. Once you know what the do, you can
control your cd-player, mp3-player or anything that uses these symbols.
To declare an interfacce you have to register a non-instantiable ...

Don't know if this is enough already. Does this sound like a good explanation to
you?

Stefan

On 2/8/07, Stefan Kost <ensonic hora-obscura de> wrote:
hi,

yesterday I committed a first batch of cleanups to the GObject docs.
http://developer.gnome.org/doc/API/2.0/gobject/index.html

IMHO this is a crucial documentation for the GNOME platform and it can
be improved further. Marc-Andre Lureau and Zeeshan Ali already joined
in the quest to improve this. What I like to ask you is to reply to
this mail and tell us what you don't understand yet, point out parts
that can be improved, let us know if there are some nagging concerns
about the way GObject works. Are there details that should be
explained by a picture?

If possible then please checkout the latest version and base your
feedback on that one:
   svn co http://svn.gnome.org/svn/glib/trunk glib
   cd glib
   ./autogen.sh --prefix=$HOME/test
   make
   cd docs/reference/gobject
   evince html/index.html &
you don't need to install it.

Thanks!

Stefan

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]