Archive for April, 2007

Cairngorm 2.2

Saturday, April 28th, 2007

After a long beta release Adobe has finally released Cairngorm 2.2, which is now available on labs.

Though only a dot release, there are some pretty significant changes which are worth mentioning; specifically the distributed binaries. For instance, Flex Data Services has a dependency on fds.swc, which is shipped with the standard Flex Framework. In order for Cairngorm ServiceLocator to contain a reference to mx.data.DataService, the fds.swc needed to be included in the Cairngorm.swc. This resulted in increased file size as all Cairngorm classes were bundled in the same swc. regardless if you needed FDS or not. Adobe has resolved this by externalizing all FDS specific dependencies to the new Cairngorm Enterprise edition.

Another major improvement is the additional dispatch() method which has been added to CairngormEvent. The dispatch method allows developers to instantiate an CairngormEvent instance and dispatch the event via the instance. In other words, the event instance can dispatch itself into the event flow without a need to invoke CairngormEventDispatcher directly. This is similar to my IViewNotifierEvent solution which is an adaptation of the Stanglware solution which was developed by my former co-worker Fred Stangl.

The ability to remove Commands from the FrontController registry at runtime is of great value. I was actually in the process of developing an API to do just that.

The WebService bug has been fixed which is also a big plus as it caused great confusion initially.

Listeners for Event / Commands now have weak references in the base FrontController, this was also an issue in Cairngorm 2.0 and 2.1 that we were struggling with as objects still had references long after they were no longer being referenced and therefore would not get picked up by GC.

I have been using Cairngorm 2.2 beta for the past few months and have found it to be a big improvement over Cairngorm 2.1 and 2.0. Below I have listed the major changes in Cairngorm 2.2 contrasted with Cairngorm 2.1 and 2.0.

Changes between Cairngorm 2.1 and Cairngorm 2.2

  • Removed dependency on Flex Data Services (fds.swc)
  • Flex SDK SWCs are no longer linked into Cairngorm.swc
  • Added support for setting remote credentials
  • Fixed bug with Web services not loading the WSDL
  • ModelLocator interface deprecated in favor of IModelLocator
  • Added deprecation metadata for compiler support
  • Added dispatch() helper method to CairngormEvent
  • Commands now added to Controller with weak references
  • Added removeCommand to FrontController
  • made commands protected in FrontController

Changes between Cairngorm 2.0 and Cairngorm 2.1

  • Responder has been deprecated. Use mx.rpc.IResponder
  • Command deprecated in favor ICommand
  • ValueObject deprecated in favor of IValueObject
  • ServiceLocator getService() deprecated in favor getRemoteObject()
  • ServiceLocator.getInvokerService() has been deprecated.
  • IServiceLocator interface has been created to support unit testing
  • ServiceLocator has security methods added
  • FrontControler.executeCommand() and getCommand() now protected
  • Error messages have been internationalized

If you are not currently leveraging Adobe Cairngorm to build scalable Flex RIAs I highly suggest you begin to explore the solutions which Cairngorm provides. I am a huge advocate of Cairngorm and strongly support Cairngorm as an architectural solution for building Enterprise class RIAs with Adobe Flex.

If you are interested in developing with Cairngorm, but are having trouble getting started, please feel free to contact me directly and I will be happy to walk you through Cairngorm and help get you started.

Download Adobe Cairngorm 2.2

AS3 Iterator API Update

Thursday, April 26th, 2007

I have updated the Iterator API to include a generic CollectionIterator which can be used to iterate over concrete IList implementations such as ListCollectionView, ArrayCollection and XMLListCollection.

I have also removed the abstract base implementation for all concrete Iterators in favor of the IIterator interface.

In case you are not familiar with the Iterator API, it allows developers to traverse an aggregate without the need to expose it’s underlying implementation. Developers can utilize the Iterator API to easily and intuitively iterate over Arrays, Collections and objects with the same Iterator instance. You can also implement the IIterator interface to provide additional concrete iterators in addition to the ones which I have provided; Array Iterator, Object Iterator and Collection Iterator.

A concrete Iterator can be instantiated directly or dynamically at runtime via the IteratorFactory. Typically, developers would type an iterator instance as an IIterator so as to utilize the IteratorFactory to retrieve the concrete iterator types as needed.

I have provided a simple example which contains the compiled source as well as the ASDoc and UML diagram.

source / example
ASDoc
UML

40 years worth of Objects

Saturday, April 7th, 2007

Of the many facets of software development which I take part in my true passion has always been Object Oriented Design, that is, I naturally tend to gravitate towards the design, relationships and interactions between objects within a system.

Currently I tend to concentrate primarily on ActionScript 3.0, however I am language agnostic in the sense that I am not driven by a particular language or simply by the solution in which a language provides, but rather by the gratification I receive from working with a language that adheres to Object Oriented Principles and the results of this practice.

I brought to my teams attention the other day at work that this year marks the 40th anniversary of the first Object Oriented language. I also mentioned this to a few former co-workers of mine whom are also fellow OO enthusiasts. They said I should blog about this milestone, and so I am as I feel many of you will find the origins of Object Oriented Programming interesting.

In the late 1960s two Norwegian programmers, Kristen Nygaard and Ole-Johan Dahl were developing a new language which would be able to naturally describe complex systems at a higher level using concepts that were much easier to grasp. This new language was called Simula 1 and was derived from an existing language Algol. Algol was a block structured language which was comprised of functions containing variables and sub functions. The owning function amounts to a data structure on the stack. The sub functions can access the variables defined within the data structure. It has been said that they experimented with moving this data structure from the stack to the heap, this way the variables and sub functions would outlive the owning function once it had returned.

Now if you read the last paragraph again you will notice that something sounds very familiar; the owning function is a constructor, the variables defined within the owning function are instance variables and the sub functions are methods.

Simula-67 - the very first Object Oriented Programming language was born!

And so I thought I would take a moment to reflect on the origins of the OO concepts which we work with on a daily basis and have come to enjoy so much.

Resource Writer API for Apollo

Saturday, April 7th, 2007

The ability to create files to a local filesystem via ActionScript is one of the main attractions of Adobe Apollo.

For years developers have been restricted by the Flash Player security model and for good reason. It was quite common to delegate the responsibility of creating files to a middle tier service. However middle-tier services only enabled files and directories to be created on the server, and not the client machine, unless the application server was running on the client machine, which for the most part is never the case.

As many of you are probably aware of by now Apollo provides Flex Developers with the ability to create files to a local file system purely in ActionScript via flash.filesystem.File. This new functionality creates endless possibilities.

Taking advantage of this, I have developed a ResourceWriter API for Apollo which allows developers to easily create .properties files to a local file system. This is useful creating localized content which needs to be modified frequently as well as many other uses.

You can view the source: ResourceWriter, IResourceWriter, IInspectableFileClient as well as download the example Apollo Application.