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: Commands as Mini Controllers  (Read 6079 times)
psyflex
Jr. Member
**
Posts: 12


View Profile Email
« 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
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>
Logged
psyflex
Jr. Member
**
Posts: 12


View Profile Email
« Reply #2 on: June 23, 2010, 07:36:27 »

Thanks for the quick response Cliff,

And thanks again for this great framework!
Logged
Pages: [1]
Print