Convert a project from PureMVC to Robotlegs

eco_bach's Avatar

eco_bach

09 Mar, 2010 12:38 PM via web

Hi
Initially have to admit was put off by the name, but have decided to take robotlegs for a spin. As a learning exercise I'd like to take one of several PureMVC projects I've created and convert them over to RobotLegs.

Can PureMVC projects be easily ported over to Robotlegs? Or, should I simply re-architect from scratch (retaining most of the code in my view components)?

  1. 2 Posted by eco_bach on 09 Mar, 2010 12:55 PM

    eco_bach's Avatar

    Although minor for most projects, 1 advantage I see PureMVC having is the much lighter compiled code base, about 12 vs 29k for Robotlegs.

    Are there plans to optimize-refactor Robotlegs further?

  2. Support Staff 3 Posted by Shaun Smith on 09 Mar, 2010 08:15 PM

    Shaun Smith's Avatar

    Hi eco_bach,

    Those sound like debug sizes to me - last I checked, PureMVC compiled down to about 5k for a release build, and Robotlegs+SwiftSuspenders comes to around 12k (also, for a release build; debug build sizes are unimportant). Robotlegs by itself weighs about 4k - but that's pretty meaningless as it won't do much without a Dependency Injection framework (like SwiftSuspenders, Spring or SmartyPants).

    Of all the available options for DI + MVC, Robotlegs is probably the smallest you can get; PureMVC + Spring, for example, would be quite a bit bigger (somewhere around 40k I'd imagine).

    With regards to porting: I've personally ported quite a couple of projects from PureMVC to Robotlegs and had no problems, but then again, I know this framework inside-out ;-)

    One annoyance might be the creation of custom event classes to replace old notifications.

    Another might relate to PureMVC's concept of named/dynamic proxies/mediators - where strings are used to match mediators to proxies. You'd need to use a different approach with RL. See: http://groups.google.com/group/robotlegs/browse_thread/thread/dd60a...

    Also, injecting mediators into other actors (models, commands, other mediators) doesn't make sense in Robotlegs as there is no guarantee that only one mediator will exist for a given view type. This boils down to basic MVC principles though - the application shouldn't know about it's view.

    Otherwise, most things map 1 to 1 with PureMVC. That said, I would dig into the demo apps and play around for a while before doing a serious port.

  3. 4 Posted by Jim Bachalo on 09 Mar, 2010 10:55 PM

    Jim Bachalo's Avatar

    Thanks Shaun!
    Where can I grab the non-debug version of Robotlegs+SwiftSuspenders?
    jim bachalo

    [c] 416.668.0034
    [w] www.tweetmasher.com
    --------------------------------------------
    "...all improvisation is life in search of a style."
                 - Bruce Mau,'LifeStyle'

  4. Support Staff 5 Posted by Shaun Smith on 10 Mar, 2010 07:18 AM

    Shaun Smith's Avatar

    Hi Jim,

    Debug vs Release comes down to how you compile your final SWF. If you are using Flash Builder 4 you can export a Release build of your project by going to:

    Project -> Export Release Build...

    Instead of compiling into a bin-debug folder, your output gets compiled into bin-release.

    I'm pretty sure it's the same with Flex Builder 3. For other IDEs/editors you'd have to check the documentation, or set a command-line option.

    Debug builds contain a lot of extra information that is not needed for a final release. Release builds are usually quite a bit smaller and perform slightly better (sometimes the performance increase is substantial).

  5. 6 Posted by eco_bach on 10 Mar, 2010 03:55 PM

    eco_bach's Avatar

    Hi Shaun

    Perhaps I'm missing something here. I appreciate all the feedback and am anxious to try Robotlegs, but when you say...'PureMVC compiled down to about 5k for a release build, and Robotlegs+SwiftSuspenders comes to around 12k'.

    How do you obtain those figures?
    I've never been able to either download or compile my PureMVC swc smaller than 12k.
    And, at least from what I've been told, the size of the swc IS the size of the final code when compiled into your swf.

    Also, please correct me if I am wrong, but I don't believe there is such a thing as a 'non-debug' version of a swc....you can only compile a FB Library project to a swc...exporting a release build is not an option. As I am still mastering the finer points of FB compilation, I may be missing something.
    Feedback appreciated...

  6. Support Staff 7 Posted by Shaun Smith on 10 Mar, 2010 04:39 PM

    Shaun Smith's Avatar

    Howdy!

    No problem. SWC files are definitely bigger than compiled release bytecode - they contain trace information, line numbers, assets, and probably more. But you're right about the fact that you don't get non-debug SWC files. SWC files have to contain debug information or we wouldn't be able to use them as libraries!

    What's more important than the size of the SWC file is the size of the bytecode that gets compiled into your final "release" SWF file. This is affected by how many classes you actually pull into your project from the library. Import statements don't count, only classes that you actually reference (and classes that they reference etc). This is called a dependency graph:

    http://en.wikipedia.org/wiki/Dependency_graph

    Code that is not in the dependency graph for your application does not get compiled into the final SWF. You could have a 5MB SWC library in your source path, but if you don't actually reference any of the classes in that library no weight is added to your SWF.

    Likewise, you might reference one class, which in turn references another, and another, and so on, and inadvertently you end up compiling all 5MBs worth of classes into your output. This happens when classes have too many responsibilities and references. The Flex framework is often criticized for this - touch one class and suddenly you've added 400k to your SWF!

    To test the size of PureMVC, for example:

    Create an empty ActionScript project with Flash/Flex Builder
    In your main class instantiate PureMVC's Facade class
    Project -> Export Release Build...
    Check your bin-release folder

    The Facade class, by way of reference, touches pretty much every class in PureMVC - not exactly, but close enough to get a good idea of the minimum weight added by the framework.

    Size tests for Robotlegs can be found here:

    http://github.com/robotlegs/robotlegs-demos-Bundle/tree/master/Size...

    Hope that helps!

  7. Stray closed this discussion on 16 Feb, 2011 09:04 PM.

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