Friday, August 19, 2011

Casting power

One of the great advantages in dynamic casting is that you can move between capabilities of any object with any one of its handles.

UIWindow * pWindow = UIWindowNew();
UIElement * pElement = UIElementCast(pWindow);
pWindow = UIWindowCast(pElement);

You can see how I can move from the element to the window to the element easily and safe.
This simplifies code a lot since I don't have to pass objects down the pipe.
Its a lot like a C++ dynamic_cast call but in ANSI C!

It makes the components that I have to write small and simple.

No comments: