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

Show Posts

* | |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Architecture / Re: Passing data to FSMs to reuse commands on: December 12, 2013, 02:28:53
Hi Cliff,

I was not asking you to implement that feature. I'm sorry if I wasn't clear enough. We are still trying to learn and we had a doubt about if "our method" would be correct or not, regarding software design. Maybe in another language, maybe in another framework :)

Many thanks for your help. We will do as you indicate.

All the best,
Luis.
2  Announcements and General Discussion / Architecture / Re: Passing data to FSMs to reuse commands on: December 11, 2013, 02:40:54
Thanks for your answer Cliff.

I understand your approach, but...

The main advantages I see are in the other approach are:
- You can have a clean, simple, commandDownloadFile without any magic "switchs" and "ifs". 100% reusable.
- You don't need X different notifications, just one (DOWNLOAD_FILE).

In a small software where commandDownloadFile is used only twice, it makes total sense. But what about a larger software with hundreds of files?

Do you see any drawback following this practice? Any case that may run into problems?

3  Announcements and General Discussion / Architecture / Passing data to FSMs to reuse commands on: December 10, 2013, 10:33:11
Hi everybody!

We are in the design phase of a project and we have a download sequence. We want to use a FSM for that. It would be something like this (this is only an example):

<fsm initial="CHECKING_CONNECTION">
   <state name="CHECKING_CONNECTION" changed="CHECK_CONNECTION">
      <transition action="CONNECTION_AVAILABLE" target="DOWNLOAD_SETTINGS_FILE"/>
      <transition action="CONNECTION_UNAVAILABLE" target="CHECKING_CONNECTION"/>
   </state>
   <state name="DOWNLOAD_SETTINGS_FILE" changed="DOWNLOAD_FILE">
      <transition action="DOWNLOAD_COMPLETE" target="CHECKING_DATES"/>
   </state>
   <state name="CHECKING_DATES" changed="DOWNLOAD_FILE">
      <transition action="NEW_CONTENT_AVAILABLE" target="DOWNLOAD_CONTENT_FILE"/>
      <transition action="NO_NEW_CONTENT" target="RENDERING_SCREEN"/>
   </state>
   <state name="DOWNLOAD_CONTENT_FILE" changed="DOWNLOAD_FILE">
      <transition action="DOWNLOAD_COMPLETE" target="RENDERING_SCREEN"/>
   </state>
   <state name="RENDERING_SCREEN" changed="REFRESH_SCREEN">
   </state>
</fsm>

Our problem here is: how do we reuse the same command (commandDownloadFile) to download both the Settings file and the Content file.

Our only idea right now, would be to include that info in the own FSM. Something like this:
   <state name="DOWNLOAD_SETTINGS_FILE" changed="DOWNLOAD_FILE" data="{ file: settingsFile.json }">
      <transition action="DOWNLOAD_COMPLETE" target="CHECKING_DATES"/>
   </state>
   <state name="DOWNLOAD_SETTINGS_FILE" changed="DOWNLOAD_FILE" data="{ file: contentFile.json }">
      <transition action="DOWNLOAD_COMPLETE" target="CHECKING_DATES"/>
   </state>

This is only an example to show a way we could solve it. Not sure how you should "add the data" to the xml FSM, but if something like that is supported, it would definitively allow us to reuse the commandDownloadFile.

Right now this is obviously not supported, so... how should we solve this? Could "adding data to the FSM" be a good/recommended way to solve these cases? Any drawback?

Thanks in advance!
Pages: [1]