Wednesday, July 30, 2008

Flex Spaghetti

We were playing internally with a Flex project and after our first Scrum sprint we ended up with a real nice looking frontend, ... but also with Flex Spaghetti! All kind of events were bubbling up and down through the application.

After searching the internet I noticed a lot of people are having the same problems. Using a framework or a blueprint architecture should help us. In Java we have a lot of frameworks to choose from, each with it's advantages and disadvantages. On the Flex side the number of mature frameworks is limited. For me this is a sign that (professional) Flex development is in it's early stages. However there are some frameworks. Luke Bayes and Ali Mills made a nice comparison of the available frameworks. Cairngorm and PureMVC scored best in this comparison and so I tried them both. I prefer PureMVC as it's much cleaner using the Mediator pattern. This allows to send event backs to the view eaily and clean as well.

In my free time I also started to experiment a little bit with AIR and it's embedded SQLite database engine. This is useful for storing local data in offline mode but also for creating small stand-alone applications like a personal Movie database. When talking to a database I'm used (and spoiled ;-) to Grails ORM (GORM) or Spring's JDBCTemplate and HibernateTemplate. There is nothing like this available in Flex/ActionScript. To write GORM in ActionScript is not an option, but to port Spring's JdbcTemplate to a SqliteTemplate in ActionScript was doable on a nice summer evenning. I'm currently in talks with Cliff Hall of the PureMVC project to add this as an utility to the PureMVC project. If you are interested in in the meantime, just leave your email address and I will send you a copy.


Anonymous said...

Hi Marcel,

One big obstacle in using AIR is its connectivity limitation (only SQLLite). Moreover, AIR is using SQLLite in pure unencrypted way, so everybody can easily read saved data.
Obviously, developer may use cryptographic algorithms to save encrypted data but it not the best solution from SQL queries perspective.

I am glad that you have spend some time to rewrite SQL access class in way as it is in Java SQLTemplate. Couple months ago I was thinking about this same. Now, I think the ideal solution would be SpringForActionScript with all IoC capabilities. Hope that soon or latter somebody will find time and share his work for everybody.

Can you send me what you have done with Spring's JdbcTemplate?

(herbat73 at yahoo dot com)

Marcel Overdijk said...


There is something like SpringForActionScript with IoC capabilities. Have a look at the Prana framework ( It's a direct port of Spring IoC.

Be aware that you if you want to instantiate classes dynamically you still need to refre to them otherwise they will not be compiled in your app. See this discussion:

Henry said...

Have you checked out mate?