Sort of like Fishing but Not

AbstractTab(tab.selectedChild.getChildAt(0)).refreshFrame();

AbstractTab(ModuleLoader(tab.selectedChild).child).showFrame();

There are some almost coherent thoughts around OOP and/or/vs DOM for UI development in my brain, but in the meantime the above code somewhat encapsulates* something that often bothers me in my Flex development. To be more specific, a mess-o-casting.

For the code-inclined here: in case it isn’t obvious, both lines are calling functions on AbstractTab, which is an interface implemented by (the children of) the child object of “tab” (a Flex “TabNavigator” object). That child is of type “ModuleLoader”, which is where it gets complicated.

I know vaguely why each line works, but it still kind of bothers me. I guess my question is, in your opinion (if you have one), which (if either) is clearer and why?

*rim-shot!

Previous: QotD

Archives | Blogroll | RSS