You are viewing the Articles published in

40 years worth of Objects

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

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.

Query String Inspector for Flex

It is common for Flex applications which are deployed to an application server to require specific parameters be provided via the applications query string.

The Flex Framework Application class provides a parameters property which contains the query string provided to the application as well as the FlashVars HTML parameters provided to the application. This is very useful as developers are no longer required to facilitate interoperability between ActionScript and other languages, typically JavaScript, just to get an swf applications query String.

The QueryString inspector is an all static class which takes advantage of this by providing an API which allows developers to perform detailed inspection of an applications Query String.

Below is a description of each method:

  • rawQueryString: Retrieves the raw query string provided to the application
  • isProvided: Determines if parameters have been provided to the application
  • nameValuePairs: Creates an Array of objects comprised of each name / value pair provided to the application
  • parameters: Retrieves the parameter names provided to the application
  • values: Retrieves the parameter values provided to the application
  • containsParameter: Determines if the specified parameter has been provided
  • containsValue: Determines if the specified value has been provided
  • getValue: Returns the value of the specified parameter
  • length: Returns the length of the query string

FileWriter API for Apollo

I have published a simple FileWriter API for Adobe Apollo which is essentially an all static class providing methods for synchronous and asynchronous File creation.

FileWriter encapsulates file creation in an all static class which can be used to easily and intuitively create files to a local file system simply by specifying the name of the file to create as well as the path in which to the file is to be created.

FileWriter will create a new file if the file does not currently exist and return an open FileStream referencing the file object via FileMode.WRITE, otherwise FileWriter will open a previously created file and return an open FileStream referencing the File via FileMode.UPDATE.

You can view the source as well as download the basic sample application which allows you to create a File to your desktop utilizing the FileWriter API.

FileStream namespace bug in Apollo

One thing that you may encounter when attempting to use the FileStream Class in Apollo is that it does not resolve to the correct package.

For instance, FileStream is mistakenly located in the flash.events namespace but is actually defined in the flash.filesystem namespace. This creates a problem when you try to import FileStream in the Eclipse IDE as intellisense will not locate the class. However, FileStream does not resolve to flash.events. FileStream and you will get a compiler error if you attempt to import flash.events. FileStream, even though intellisense will find it.

So the solution is to simply import flash.filesystem.FileStream as it is intended to resolve to this package even though you will not see it using intellisense. This is a weird bug that can leave you scratching your head for awhile so I thought I should mention it here.

Remember that this is just the initial Apollo Alpha and I am sure that this bug will be addressed in the next release.

Cairngen Roadmap

It has been awhile since I initially posted the pre-alpha release of Cairngen in early January. As I had mentioned in the original post, Cairngen was simply a tool which I created to help speed up my own personal development process when building Flex applications with Adobe Cairngorm. My intentions were to share the project “as is”, as I had assumed other developers would certainly benefit from using Cairngen to quickly generate Cairngorm classes and project directories. I have since received numerous E-mails from many developers who are using Cairngen and the feedback has been very positive.

In part, I released Cairngen to demonstrate just how easy it was to build a simple tool to generate Cairngorm projects and templates. From start to finish the pre-release version of Cairngen took around 6 hours or so. Another reason I released Cairngen was in the hopes that other developers with the required time available would take an initiative and build a proper Eclipse based plug in version of Cairngen.

Since Cairngen’s pre-release, there has been many developers building their own versions of Cairngen in other technologies, and I see this is as a very good thing for the community. Originally, I was contemplating releasing Cairngen to the community as an open source project in order to allow developers the ability to extend the APIs to suit their particular needs. This would alleviate much of the need for my continued maintenance and support of the project.

So what is the future of Cairngen moving forward? Ultimately, I have decided to re-develop Cairngen from the ground up as an Apollo application. Building Cairngen in Apollo will give me maximum flexibility and allows Cairngen to run as a stand alone application. I still have some additional research to complete before I can officially confirm, however, it will definitely be possible, and it will also help build interest in the Apollo community as well.

So if you are developing applications with Cairngen you can expect the version 1.0 release to be available as an Apollo application shortly after the alpha release of Apollo is available. If you have any requests for the 1.0 release feel free to comment.