Joey Robichaud

code and thoughts

The Story of Asfac

Asfac is a simple IoC container for ActionScript and this is the story of how it came into being.

Genesis

It is all Jon Skeet’s fault really. I rediscovered this gem of a video he recorded with Rob Conery for a series on TekPub. In the video Jon creates a functioning IoC container in matter of minutes.

I was unfamiliar with the concept of containers at the time, but the basics looked simple enough. So I set out to learn more by implementing a container for ActionScript. Why ActionScript you might ask? I wanted to explore the concepts without directly copying Jon’s code. My first stab at the container lives as a gist and is a pretty straight port of Jon’s code. A good start perhaps, but I wanted better.

Work in Progress

Asfac represents my first project written with a TDD approach and an excuse to try out new development processes. After getting Dave on board, we paired going back and forth one writing a failing test; the other writing the code that would make it pass. This went on for a while until we had gotten the equivalent of Jon’s container working in ActionScript. I was excited. Not only did TDD keep me very focused on individual requirements but pairing was great for keeping me on task.

With a functional container written, Dave wanted to see how far we could push it. He had already been using containers in his .NET work and wanted to bring some sugar over. So we started making our wish list of functionality; things like a fluent interface, scoped registration, and property injection.

We then entered all this information into GitHub. We took advantage of the issue tracking for logging bugs and enhancements, worked in feature branches during development, and issued pull requests for the other to code review. Basically what I consider to be a healthy development process.

Stick in the Mud

With development of all the functionality wrapping up there was only one task left to accomplish, Documentation. We knew that asfac certainly didn’t need a book to use, but it did need to be documented. Dave opened an issue and created a branch. He reorganized the sample code in the read-me this time with better descriptions. We started reviewing the API documentation in the AsDoc comments and then it all stopped. Months passed with a releasable version of asfac sitting around waiting to be documented.

The new year has a way of stirring some self reflection. Over the winter break I started making a mental list of where I could improve over the next year. One area that seems to be on every year’s list is ‘finishing’. Why wait another year to see if I could get better at it? Start finishing now!

I cloned the asfac repository and gave it a proper review. I standardized things like comments being in sentence structure not as fragments, fixed variable names that had long since changed in the code, and pushed it all up to GitHub for a final look over. It only took a week to sync up with Dave and get it all merged into master.

Wrap up

So it took a while but we are at v1.0. We finished something we started. Success! So if you are using ActionScript and have need of an IoC container, then please take us into consideration with all the others and let us know how we stack up.

asfac on GitHub

This post originally appeared on The DevStop.