Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3199

Have FactoryBuilderSupport call factory methods through the MOP

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.6-rc-1
    • None
    • Swing
    • 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
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            shemnon Daniel Ferrin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: