Monday, April 12, 2010

OO's N-levels of indirection

OO relly frustrates the daylights out of me sometimes.  You find a function that gets passed an IThing, which has referectes to other IThingies.  In working with some code, you find there there is a call to an IThing.IThingy.Foo, and you try to determine which piece of code is responsible for it.  Good luck.

This anoying trip ussually starts with trying to figure out what classes implement which interfaces,  something that VS2010 still doesn't seem to make trivial (maybe my Kung fu is just not strong).  Trusty Reflector to the rescue.  If you are lucky, there is only one implementor, and this journey is over.  If you are not lucky, you get to try to traverse the call stack, to see which implementation got instantiated and passed to the function at hand.  If your are completely unlucky, there is a dynamic (i.e. reflection) call somewhere in there, at which point your brain segfaults.

No comments: