I'm just starting to use Prana and am adding it to an existing project. The project is a Flex frontend with a Grails backend. The grails backend will provide the current data and accept updates from the flex frontend via httpService objects. Currently I am not using a MVC framework. I might retrofit one later, but I'm too close to deadline right now.
I am wondering about what would be considered a Best Practice for dealing with data. The data can safely be modeled with a singleton data object. In both of my examples the html launch page is dynamically generated and the id of the object we are interested in would passed in via the flashVars parameter.
Here are my thoughts on my options.
- Dynamically generate a file, id.xml, as the application context and include the data inline. Construct a dataCommit HttpService in the applicationContext.xml
Example:Code:<object id="assessment" class="valueObject.Assessment"> <property name="name" value="some name"/> <property name="id" value="id value"/> <property name="childObjects"> <value> <array-collection> <object .../> <object .../> </array-collection> </value> </property> </object> <object id="dataCommiter" class="service.HttpDataCommiter"> <property name="url" value="serviceurl/path/to/commiter/<id value>"/> </object>
- Static applicationContext pointing at a dataSource and dataCommit object. Use the id as a parameter in the http service calls.
Example:Code:<object id="dataSource" class="service.HttpDataSource"> <property name="url" value="static url to data generator"/> </object> <object id="dataCommiter" class="service.HttpDataCommiter"> <property name="url" value="static url to data commiter"/> </object>
The advantage to the first option is only one round-trip to the server to load the data, but the disadvantage is the app will have a slower perceived load time.
Another advantage to the first object is that it is instantiated as soon as the applicationContext is loaded, and can just be accessed immediately, where the second version has to make a second asynchronous call and have a handler called when the data is loaded. So the logic for the second method is a little more convoluted.
Any thoughts? Am I missing something?