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

Click to download source code

View source code

Check out the source code: View source code

Download full source

Full source of the example: SwizAIRSQLiteExample.zip (Downloads: 1352)

Acknowledge

6 Responses to “Swiz example based on Adobe AIR and SQLite”

  1. Sönke Rohde Says:

    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.

  2. sectore Says:

    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

  3. Jon Toland Says:

    How do you feel about the relative strengths of the frameworks now having been involved with Swiz, Mate, and PureMVC and Pipes?

  4. sectore Says:

    @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

  5. Jon Toland Says:

    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!

  6. Peder Says:

    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?

Leave a Reply

Follow sectore on Twitter