Package Scan versus Mapping

andre's Avatar

andre

11 Jan, 2012 07:30 PM

Hi,

What is the rationale for having to have mapping files to explicitly map things like commands to events and for injection versus using a package scanner that does this automatically by looking for metadata tags in the code ? Having to do this manually makes the code bigger and more brittle without any benefit AFAIK.

Is there already a mechanism for package scanning ? If not, is this on the product roadmap for RobotLegs 2 ?

Thanks !

  1. Support Staff 1 Posted by Till Schneidere... on 11 Jan, 2012 09:30 PM

    Till Schneidereit's Avatar

    Hi andre,

    Robotlegs (and its dependency injector, Swiftsuspenders) do use a fair
    amount of metadata to facilitate dependency injection with little
    coding overhead. injection is done automatically for every instance
    except for the root of an object tree. How would a package scanner
    know when to create a specific object tree? That's something only the
    developer can decide and codify in their application logic.

    As for automating mappings, there are several problems with the
    package scanner approach:

    - Mapping commands to events would entail having custom,
    non-standardized metadata. That in turn would move parts of the logic
    out of statically checked code into runtime-detected metadata which
    you don't even get any errors for if you get it wrong.

    - You have to somehow compile all the required classes into your SWF
    anyway. That entails mentioning them somewhere.

    - Even if you use package includes with the compiler to get all
    classes into the SWF, there's no way to find all classes in a package
    without having a list of them (short of parsing the SWF yourself,
    which is *very* expensive).

    - You might want to dynamically activate and later deactivate
    mappings. How would you do that with a package scanner approach?

    - How would you deactivate mappings without deleting entire classes
    (or at least specific lines of metadata)?

    Maybe I'm misunderstanding something, but it seems to me like these
    are important problems that prohibit a package scanner from being a
    workable solution.

    cheers,
    till

  2. Ondina D.F. closed this discussion on 23 Feb, 2012 10:34 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac