[Gtk-sharp-list] Associate user data object with a widget

newszi amocsy at gmail.com
Mon Jan 4 09:30:41 EST 2010




Andy Selvig wrote:
> 
> I've been reading this conversation, and just figured I'd give my two
> cents.
> 
> I have to agree with Chris 100% on this. First off, comparing it to
> Python is a bit apples/oranges. Even though a hashtable approximates
> Python property system, that is the "Python way" to do things. It's a
> dynamic language and people use it for situations where they're okay
> with no type safety or collision avoidance.
> 
> The argument that it's "okay" to C users is a bit misleading as well.
> One of the best things about C# (and Java) is that it actually has a
> strong runtime type system. The C type system is a compiler
> convenience that can mostly be ignored by the developer if they
> choose. For example, I could store some user data in C that's a
> string, then dereference it as an int and go happily along my way
> without knowing that the value will be meaningless.
> 
> Of course, in C#, this will throw a runtime exception. But it's not
> the "C# way" to do it. If you want to store user data, either subclass
> the widget and give it a proper name/type, or store a separate
> (strongly-typed) dictionary. It all depends on the exact application,
> but either way, just throwing data into a grab bag is ignoring the
> type system that makes C# awesome.
> 
> Anyway, sorry to budge in, just my 2 cents.
> 

Since C# objects both have getHashCode() method and the Tag property,
arguments, that they are 'not
the "C# way" to do it' doesn't just feel right to me.

Another note, that the C# 2.0 way (as stated by the guy (I forgot his name)
who led the .net 2.0 framework development back then) is following the so
called '80-20 rule'. Which means that 80% of the functionality are there to
be easily usable, and fasten the development, while allowing to do
everything possible, in the remaining 20%. So we can actually do everything,
we could have done in native code. Like we have unmanaged pointers in
.net2.0.
So the "C# way" in my opinion is: Being able to most of the things easily,
while being able to do everything.
That's why C# is my favourite more than five years now.

By the way, I actually looking for a winForms Tag like functionality for
libglade gui file.
Is it possible to define some text or number in a glade file which get's
readable in C# code using gtk# and glade#?

Greets,
Andrew
-- 
View this message in context: http://old.nabble.com/Associate-user-data-object-with-a-widget-tp26524503p27013702.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.



More information about the Gtk-sharp-list mailing list