PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: psyflex on June 23, 2010, 01:34:38



Title: Commands as Mini Controllers
Post by: psyflex on June 23, 2010, 01:34:38
Hello Everyone,

I want to begin with mentioning that the PureMVC is awesome!!

A quick verification:

Is it ok to group related commands into one command, and call this command with different types to execute different sub-commands ?

An example:

I have a CreateProductsView, it has SUBMIT and INIT commands (usually there is more in my app),

I create a main Command called: "CreateProductsCommand" link it with "EXECUTE_CREATE_PRODUCTS_COMMAND" notification, and call that notification with type "INIT".

This way I can save the amount of command classes and notifications, and create a "mini controller" to that view, where if you want to look or changed anything, it is all under the same place (only in case other places doesn't need to use the same code of course)

Is it good practice? are there better ways?

Thanks,
Shai


Title: Re: Commands as Mini Controllers
Post by: puremvc on June 23, 2010, 07:18:10
You can certainly do this, there's nothing wrong with it.

It's not reducing complexity, its more like squeezing the air from one side of a balloon to the other. Reduced number of commands and notes, but the operation of this combined command is more complex since it has 2 or more 'modes'.

That said, as long as you've clearly documented the code in the command and the modes make sense being combined into the same command, then I'd say go for it.

-=Cliff>


Title: Re: Commands as Mini Controllers
Post by: psyflex on June 23, 2010, 07:36:27
Thanks for the quick response Cliff,

And thanks again for this great framework!