Archive for the 'Design patterns & theory' Category

Architectural Atrocities, part 9: Cairngorm’s Model Locator pattern

From time to time I re-read the introductory articles on Cairngorm just to remind me of why I don’t use it and never will. This installment of the Architectural Atrocities series is a critique of the Cairngorm framework, and the Model Locator pattern in particular.

Read the rest of this entry →

Separating event handling from event filtering

One thing that bugs me with event handling is that usually I’m not interested in every event that comes my way. This makes my event handlers more about filtering events than handling them — for example checking that shift is pressed when a KeyboardEvent comes around, or checking that a MouseEvent is above a specific area of a panel. To separate the concerns of filtering and handing I’ve come up with some AOP-like looking ActionScript. Read on for the full explanation.

Read the rest of this entry →

Asynchronous API:s and garbage collection

The asynchronous API:s in Flash, Flex and AIR don’t all work the same in regards to garbage collection. I discovered this the other day when testing out file uploading in Flash. I made the mistake of not keeping a reference to the object that was going to dispatch events when the user had selected a file. It took me half an hour to figure out what was happening, and once I did I cursed myself for not seeing it straight away. However, after having thought about it I think that the the Flash, Flex and AIR API:s are inconsistent and a bit unintuitve on this point.

Read the rest of this entry →

The beauty of namespaces

Namespaces in ActionScript is a concept which I’m not aware of existing in any other language*. I’ve tried to find an example of why they are needed and how they can solve problems that cannot be solved without them, or at least less elegantly without them. Reading Colin Moock‘s Essential ActionScript 3.0 I came accross an example that showed just that. In two paragraphs Moock has convinced me of the beauty of namespaces.

Read the rest of this entry →

On the good use of the singleton design pattern

The most common argument against using singletons can be summarised in this quote:

When you mention singletons it’s common to get a dismissive reply, something in the lines of “singletons are only glorified global variables”.

This is not unlike how I have treated suggestions to use the singleton design pattern as a solution to a problem. However, there are good uses of the pattern too, and in this post I outline one of them.

Read the rest of this entry →

Using Dependency Injection to simplify parallel development in Flex and Apollo

In this article I’m going to show you how to use dependency injection in Flex and how to use that to support parallel development in Flex and Apollo. Along the way I’m also going to talk about the Data Access Object pattern.

Read the rest of this entry →

Architectural Atrocities, part 7 / MXMLC WTF (6): Some types are less equal than others

An object of type Number, int, uint and Boolean cannot contain null. You may find it obvious, but I find it weird and disturbing. Disturbing enough to include it in my series on architectural atrocities in ActionScript.

Read the rest of this entry →

MXML and Dependency Injection

I am a huge fan of the Spring framework for Java because it helps me to build applications that are very loosely coupled. When I look at MXML it seems to me that it could be used in a similar fashion to Spring’s application context. In this article I’m going to explore that possibility and talk a little about why loose coupling is good.

Read the rest of this entry →

Architectural Atrocities, part 6: No, that is not a singleton

What does the classes Stage, Key, Mouse, Selection, ExternalInterface from the ActionScript 2.0 API:s have in common? They are bastadized singletons.

The really sad part is that of the five, three are still in the API:s in ActionScript 3.0 and of those Mouse and ExternalInterface are still bastardized singletons. Stage has been refactored completely and Key and Selection have been replaced or removed.

Read the rest of this entry →

Holub on XML

XML is perhaps the worst programming language ever conceived.

As usual, Holub is right on the spot. He talks about the perversities XML is used for, in the name of “simplicity” or other lunacies. In this blog I have occationally noted the lack of understanding of what XML really is, and Allens article is on the same lines.

Read on for a link to the article and some more commentary.

Read the rest of this entry →