On Thu, Nov 26, 2009 at 3:49 AM, Chris Howie <[email protected]> wrote: > On Thu, Nov 26, 2009 at 6:37 AM, Chuck Esterbrook > <[email protected]> wrote: >>> The reason that the "user data" mechanism is marked obsolete is >>> because it's completely the wrong way to model something like this and >>> usually creates more problems than it solves. >> >> Putting a value in a hashtable owned by an object isn't much different >> than putting a value in a variable owned by the object. In fact, some >> languages like Python even store their object variables using a >> hashtable! > > Comparing Python to a tag/data property is comparing apples and > oranges, see below.
Given that GLib.Object's UserData is returning a Hashtable, it's actually almost the same thing with the same pros (flexibility and rapid prototyping) and cons (potential collision, misspelled name and lack of typing) that you mentioned further in your reply. Python objects have those very same pros and cons. >> There are several GUI framework authors who think user data is okay >> given that GUI libs tend to have this feature including GTK+, >> WinForms, WPF and Silverlight. See also: >> http://stackoverflow.com/questions/1058635/common-uses-for-the-tag-property >> >> I've used this technique in other GUI libs without experiencing a >> single problem. It's just an alternate way to stash data in an >> existing object. > > The main problems with this approach are type safety and collisions. > ... I understand your extreme dislike for it and won't argue against you here. I just feel that if it's available in the GTK+ library to C users, then it should also be available to C# users without Obsolete attributes and scary documentation about garbage collection disasters. Let the developer decide. -Chuck _______________________________________________ Gtk-sharp-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
