Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: A little modular question  (Read 7092 times)
lostatoll
Jr. Member
**
Posts: 15


View Profile Email
« on: November 05, 2009, 11:15:55 »

Hi, I'm having a great time learning PureMVC, and it's so awesome. Thanks Cliff!

So my question lies with creating modules. I have my application shell that is a simple xml controlled structure. And I also created a slideshow module. My shell is using a version of a swf address mediator as the main dynamic notification structure. The thing I for see happening, is that if someone goes directly to a deep link, and my slideshow module hasn't been loaded yet, it obviously won't be able to react properly to the page change notification. So does this mean that I should load and create all my separate modules initially before my address mediator? In my startup command or my initializing mediator? I assume that would be the best way to handle it, but also liked the idea of loading the modules when they're needed, which sounds proper. Perhaps I have a command that checks the deep link and loads the appropriate module? I'm sure there are a lot of ways to do it, and I could use some advice.

Much appreciated.

Russ
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: November 06, 2009, 08:44:36 »

As is usually the case, there are a number of ways to handle it, all depend on your specific situation.

If you had 50 modules and a deep link might take you to any of them, you would want your deep link logic to determine at the time you're attempting to navigate which module to load or if it's already there. You wouldn't want to load 50 modules if the user might only visit one.

If you only have one or two modules and they're small you might want to simply load them before handling any navigation. In fact, you don't even have to load the modules at all, you could simply instantiate them inside the shell if there is no other overarching reason to load them. In fact that could give you the shortest initial load time.

If you look at the old code for Sea of Arrows1 (before it was pulled out into the framework that also drives PureMVC TV - a narrated slideshow), you will see how I handled it. I had only a few modules and their plumbing architecture is fixed, so I compile them directly into the app and just instantiate them. This gives me the extra level of code separation afforded by a modular solution, but loading them was a pointless step since they're all required. I can always break one of them out of the codebase, compile it separately and load it if need be, so there's no harm in going modular but not dynamically loading the modules themselves.

I used a the StateMachine utility to carve up my runtime into discrete states - plumbing, configuring,  assembling, navigating.2

First, I instantiate and plumb the modules, then read and distribute configuration to the modules, then assemble the view components, and finally handle navigation. Also, note in the link to the slide below, I am doing swfaddress-style navigation directly to a specific slide. But I'm using Flex's BrowserManager instead of swfaddress.

1 Sea of Arrows codebase: http://seaofarrows.com/srcview
2 A slide showing the FSM for the Sea of Arrows player: http://puremvc.tv/#P004/T435

-=Cliff>
Logged
lostatoll
Jr. Member
**
Posts: 15


View Profile Email
« Reply #2 on: November 06, 2009, 11:32:33 »

excellent! the sea of arrows code is a great starting point. as I learn I have to remember to keep coming back to things i once didn't understand. Time to make my first state machine!
Logged
Pages: [1]
Print