[Gtk-sharp-list] Interface Name Patch

Vladimir Vukicevic vladimirv@gmail.com
Wed, 26 May 2004 18:39:02 -0700


On Wed, 26 May 2004 17:54:08 -0700, Samuel Kaufman <skaufman@elite.net> wrote:> 
> No API clarity?  It's one of the best things you can do with C# to
> improve API clarity.  When declaring what classes/interfaces a new class
> inherits from, it can become an annoying job to figure out if one is
> inheriting from an interface or class.  Of course, if a user would never
> need to implement one, then why are they public?

Good point; you could make a case that they should be internal. 
However, there are times when you want to be able to use the interface
-- TreeModel is a good example, because ListStore, TreeStore,
NodeStore, and anything derived from ManagedTreeModel can be treated
as a TreeModel, even though they have different implementations of the
TreeModel's methods.

> The inconsistency is the annoying bit.  Why does ITreeNode have the
> preceding I, for instance?

Becuase ITreeNode is intended to be used directly by managed code. 
You cannot take a GInterface such as TreeModel and derive directly
from it; you need to do a lot of munging and p/invoke to tell the
GObject system that you implement an interface, and where the entry
points are.  Because C# does not support multiple inheritance, for
every combination of GInterfaces (and a base GObject), you need to
implement a custom abstract C# base class -- ManagedTreeModel is
relatively simple, because it just derives from GObject and implements
a TreeModel.  If you wanted to implement, say, both the GtkTreeModel
and GtkFileSystem interfaces, you couldn't use ManagedTreeModel, but
would need a new ManagedTreeModelFileSystem or somesuch.

ITreeNode, on the other hand, is a purely managed interface; there is
no equivalent GInterface.  Thus, you are able to (and are expected to)
just use it as any normal managed runtime interface.

    - Vlad