Archive for the 'News' Category

AIR Cairngorm 2.0

Sunday, June 22nd, 2008

I have received quite a few emails since the release of AIR 1.0 and Flex 3.0 regarding the AIR Cairngorm API which I developed last year. In the time since I have been working primarily with a modified version of AIR Cairngorm which I used on a number of successful real world AIR applications, however I simply have not had the time to document and refactor for general use until recently.

In case you are not familiar with AIR Cairngorm it is an open source project built on top of Adobe Cairngorm which provides a framework for working with the Adobe AIR SQLite API while building an application with Cairngorm.

AIR Cairngorm is built around the SQLService class which essentially wraps the AIR SQL APIs to provide a uniform interface which can be utilized as a service, much in the same way one would work with RPC services in a typical Cairngorm application. SQLService provides an API for both synchronous and asynchronous implementations.

In the time since the initial development and release of AIR Cairngorm, which was during the early alpha releases of AIR, there has been many changes to the SQL APIs in AIR. In addition I have also developed some new best practices for working with Adobe AIR and Cairngorm, all of which I tried to roll into this latest release where possible.

The following is a brief description of the current AIR Cairngorm API:

AIRServiceLocator: The AIRServiceLocator is a sub class of Cairngorm ServiceLocator, therefore it inherits the same API as ServiceLocator while also adding additional support for working with local databases via the getSQLService and hasSQLService methods.
AIRServiceLocator

SQLService: The SQLService class essentially wraps the SQLStatement and SQLConnection classes. SQLService allows developers to create an mxml implementation defined on a Cairngorm ServiceLocator just as one would with typical RPC services (e.g. HTTPServices, WebService etc.)
SQLService

ISQLResponder: ISQLResponder provides a consistent API from which asynchronous SQLStatement execution results and faults can be handled. ISQLResponder is very similar to IResponder in that it defines both a result and fault handler however with a slightly different signature which is specific to a SQLStatement result / fault, (i.e. strongly typed parameters).
ISQLResponder

SQLStatementHelper: SQLStatementHelper is an all static utility class which facilitates substituting tokens in a SQL statement with arbitrary values.
SQLStatementHelper

I have also created a custom version of my Cairngen project specifically targeting AIR Cairngorm code generation. In addition I will be making some future updates to AIR Cairngorm which will include support for various other AIR APIs in Cairngorm, so stay tuned.

Below I have provided downloads to the source, binary, air.cairngen and asdocs as well as asynchronous and synchronous example projects:
source
binary
examples
asdoc
air cairngen
air cairngorm (all)

IExpense Online (IEO)

Wednesday, April 16th, 2008

With Income Tax Returns approaching, now is as good a time as ever for me to blog about IExpense Online (IEO).

IExpense Online is the creation of my friend and co-worker Michal Glowacki. It is one of those Flex apps that really showcases what can be accomplished in Adobe Flex with a little creativity and dedication.

Built entirely in Flex, Cairngorm, PHP and MySQL, IExpense is a Free Tool which allows users to intuitively and intelligently manage their expenses and make sound budgeting decisions. You can try it out by logging in as a guest or creating a free account.

So make the most of your tax returns and check out IExpense Online (IEO).

IExpenseOnline

Cairngen Project moved to Google Code!

Monday, March 31st, 2008

Since the initial release of Cairngen 1.0 there has been an amazing amount of interest in the project and your feedback has been very encouraging. In addition I have received a number of extremely valuable customizations from community members, many of which have made it into subsequent releases.

In order to provide a solid foundation to help facilitate a collaborative Open Source initiative for the Cairngen Project I have decided to move the project to Google Code.

Moving Cairngen to Google Code allows for a number of significant development benefits for the Cairngorm Community. This includes regular development updates, access to all releases, availability of all source code revisions, better documentation, defect lists, feature requests and much more.

I am currently accepting requests for new contributors so if you feel you have added new functionality which would provide benefit to the project visit the Become a Contributor page. All comments on the project are welcome and encouraged. In addition I strongly recommend the if you have any issues with Cairngen, especially environmental issues you should log them to the Issues Page.

Along with the new Cairngen Google Code Project I have also released Cairngen 2.1.1 which aligns the source project with the new SVN repository.

So go check out all of the new information on Cairngen at the new Cairngen Project Home.

Principle of Least Knowledge

Saturday, February 2nd, 2008

One very important (yet often overlooked) design guideline which I advocate is the Principle of least knowledge.

The Principle of Least knowledge, also known as The law of Demeter, or more precisely, the Law of Demeter for Functions/Methods (LoD-F) is a design principle which provides guidelines for designing a system with minimal dependencies. It is typically summarized as “Only talk to your immediate friends.”

What this means is a client should only have knowledge of an objects members, and not have access to properties and methods of other objects via the members. To put it in simple terms you should only have access to the members of the object, and nothing beyond that. Think if it like this: if you use more than 1 dot you are violating the principle.

Consider the following: We have three classes: ClassA, ClassB and ClassC. ClassA has an instance member of type ClassB. ClassB has an instance member of type ClassC. This can be designed in such a way which allows direct access all the way down the dependency chain to ClassC or beyond, as in the following example:

// ClassA defines a member of type ClassB and provides
// access to the instance
public class ClassA
{
    private var b:ClassB;
   
    public function getB() : ClassB
    {
         return b;
    }
}

// ClassB defines a member of type ClassC and provides
// access to the instance
public class ClassB
{
    private var c:ClassC = new ClassC();
   
    public function getC() : ClassC
    {
         return c;
    }
}

// ClassC could expose additional members and on and
// on creating more and more direct dependencies
public class ClassC
{
    public someType:SomeType;
    …
}

// client implementation
var a:ClassA = new ClassA();
var sometype:SomeType = a.getB().getC().someType;
 

The above example is quite common, however it violates The Principle of Least Knowledge as it creates multiple dependencies, thus reducing maintainability as should the internal structure of ClassA need to change so would all instances of ClassA.

Now keep in mind that in all software development there are trade-offs to some degree. Sometimes performance trumps maintainability or vice-versa, other times readability trumps both. A perfect example of where you would not want to use The Principle of Least Knowledge is in a Cairngorm ModelLocator implementation. The Cairngorm ModelLocator violates the Principle of least knowledge for good reason - it simply would not be practical to write wrapper methods for every object on the ModelLocator. This is the main drawback of the Principle of least Knowledge; the need to create wrapper methods for each object, which are more formally known as Demeter Transmogrifiers.

The goal of good software design is to minimize dependencies, and by carefully following the guidelines provided by The Principle of Least Knowledge this becomes much easier to accomplish.