Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
1.6-rc-1
-
None
-
None
Description
Currently the FactoryBuilderSupport dispatches methods to the FActory interface via Java's dispatch logic, i.e. no multi methods. However, via InvokerHelper we could push the dispatch through the MOP, gaining us multi-methods and meta-class based dispatch.
The big win would be multi-method dispatch. Factory code that looks like this:
setParent(FactoryBuilderSupport builder, Object parent, Object child) { if (parent instanceof SGGroup) { parent.add(child) } else if (parent instanceof JComponent) { SGPanel sgp = new SGPanel() sgp.scene = child parent.add(sgp) } }
would be come this
setParent(FactoryBuilderSupport builder, SGGroup parent, Object child) { parent.add(child) } setParent(FactoryBuilderSupport builder, JComponent parent, Object child) { SGPanel sgp = new SGPanel() sgp.scene = child parent.add(sgp) } // this is un-needed actually since AbstractFactory has a do-nothing setParent! setParent(FactoryBuilderSupport builder, Object parent, Object child) { // do nothing with it }