Welcome to

Magenic Technologies Community Blog

Sign in | Join | Help

Aaron's Technology Musings

Who let this guy on the podium?

Coming soon in i4o...

As this i4o idea starts really moving, we have received some great feedback about where to go next with it.  So, with no further delay, here are the next pieces of the puzzle:

Handle Removes - This is the simplest of the changes upcoming - to prove the concept of i4o, we obviously had to be able to Add items.  Removes - we have not yet implemented, but doing so will be rather simple - in each index, look up the item and remove the reference, and when done, call the base remove.  This one should be doable very quickly.

Handle Updates - On the other end of the axis, and the big question I have been pondering every since Anders Hejlsberg brought it up to me in an email - is that updates are the real tough nut to crack.  In this scheme, where we are indexing objects that, themselves, are unaware of the fact that they are indexed collection - it is devilishly difficuly to know when you need to update an index.

Of course, there are ways to do it.  Anders pointed to PropertyChangeNotifications as one approach.  To me - it seems the most straightforward of the approaches.  That said, I seriously thought about somehow using Reflection.Emit to give some events to classes, and further, somehow sprinkle the notifications in the class directly.  Problems there range from a.) is it even possible to change an specific method's implementation at runtime (i.e. like you can in LISP - I really don't know) - and b.) even if you could, I shudder to think of the side effects that it could cause - i.e. objects all over the place putting code dynamically into other objects - which frankly, sounds like the most nightmarish thing to debug that I could ever devise.  I thought more and more, and decided that I will, for now, go the less ambitious route and head towards property change notifications.

Updates will depend on implementing INotifyPropertyChanged on your indexable object, and then raising events for property change inside your class when applicable.  While less "free as in beer" as the implementation is when you don't have to worry about changes - it does provide a well worn path for making dynamic objects indexable (as in, you can live search or google for "how to implement INotifyPropertyChanged", and get answers.

The other big suggestion, courtesy of Oren Novotny, is to build a version that inherits from BindingList<T>, which would allow you to take ListChanged events - run them against the expression tree, and make it possible for a data bound control to expose new items dynamically.  We should have this in soon as well.

Any other ideas, suggestions, or thoughts are certainly appreciated!

Published Tuesday, April 24, 2007 3:21 PM by aarone

Filed under: , ,

Comments

No Comments

New Comments to this post are disabled
Powered by Community Server, by Telligent Systems