Swiz example based on Adobe AIR and SQLite
January 7th, 2009
About two months ago Sönke Rohde, a good friend of me and a very active contributor of the Swiz framework, told me about his experiences using Swiz and he recommended highly Swiz as a framework which seems brutally simple to use. For all the people out there who are not familiar with Swiz: Swiz is an IoC framework created by Chris Scott to simplify the development of Flex based RIAs.
After diving into Objective-C for the last two weeks I have now the time to dive into Swiz. So I ported my latest published example using Mate into Swiz.
The following example is a tiny AIR based application for storing user names into a SQLite database. It includes Eric Feminellas awesome AIR SQL Framework and a way to use the Presentation Model pattern within an AIR application as well.
Screen shot
View source code
Check out the source code: View source code
Download full source
Full source of the example: SwizAIRSQLiteExample.zip (Downloads: 1352)
Acknowledge
- Video – 360|Flex, San Jose 2008 – Chris Scott: Introduction to the Swiz Framework for Flex
- Sönke Rohde: Mock Business Delegates with Swiz
- Tony Hillerson: FrameworkQuest 2008 Part 4: IoC With Swiz
- Swiz wiki pages at Google Code



January 7th, 2009 at 5:52 pm
Hi Jens, nice example.
Just a few things you might consider.
You can use chaining like:
Swi.setStrict(true).loadBeans(…)
You can use autowire by type so you could write:
[Bindable]
[Autowire]
public var mainModel: MainModel;
Restriction is that only one bean with that type exists. This is especially usefull when you autowire against interfaces to easily switch between real and mock implementation without worrying about the bean name.
Maybe it makes sense that your delegates return something. When I work with remoting they always return the AsyncToken so I can use executeServiceCall and avoid custom responders.
January 7th, 2009 at 6:35 pm
Hey Sönke,
thanks for your very helpful comment! I’ve already updated the source code based on your tips
An AsyncToken for the UserDelegate which call a “SQLiteService” could be difficult to implement, because it has to be a kind of a “SQLiteAsyncToken”.
For using Eric Feminellas AIR SQL Framework I decided to use a custom responder within UserDelegate. So a MockUserDelegate could it implement as well… Any idea for a (SQLite)AsynToken solution or something like that?
Thanks again!
-Jens
January 8th, 2009 at 1:21 am
How do you feel about the relative strengths of the frameworks now having been involved with Swiz, Mate, and PureMVC and Pipes?
January 8th, 2009 at 8:44 am
@Jon: Your question is a pretty good question! And not easy to answer
All these frameworks are absolute great and each of them has pros and cons. But what are the pros and cons? It only depends on your project needs and last but not least of the skills of the developers, which are involved at the project.
Personally I have no favorite so far and I’m very new to Swiz. However, Swiz has the great advantage to structure your code as you need without any boilerplate code. Because Swiz does not impose any pattern such as Cairngorm or PureMVC it does. But that means you have to need a good understand of common design patterns to build a well structure application using Swiz.
To deep into all these frameworks as quick as possible and to compare it check out the great series at InsideRIA by Tony Hillerson called “FrameworkQuest 2008″. Tony has built one application using PureMVC, Cairngorm, Mate and Swiz. Here are the source code of his app: “A simple twitter client for Adobe AIR, written five ways”
-Jens
January 8th, 2009 at 5:12 pm
I’ve been tracking Tony’s articles closely as well as the 360 presentations when they were released on AMP and even gave your articles a shout-out in my last comment on his “Exciting Conclusion”
I would love to hear if you have any preference as you continue to spend time with Swiz and Mate though. I used to read your blog when I was learning PureMVC. Would you mind posting a “View source code” link for the Mate example? I was going to just browse SVN via the web interface but for some reason it didn’t work
If not I can just stop being lazy and pull it up in Eclipse!
March 9th, 2009 at 7:10 pm
Hi, when I import your example into Flex 3 and try to run it I get the following error message:
File does not exist: /Applications/Adobe Flex Builder 3/sdks/2.0.1/bin/adl.
Any ideas?