AS3 on PureMVC, round one - Article by João Pescada

Articles

AS3 on PureMVC, round one

6th January, 2010

3 min read
👮‍♂️ This is an old article, that I keep online just for reference. Some links may be broken.

As referenced in the title, this article is about coding Actionscript 3.0 in a Model-View-Controller design pattern, namely the PureMVC way.

Problems don’t exist. Only opportunities for creating solutions.

A few years back, when I started on web design / development, it was a one-man show. I then started working with other developers from time to time. Two years ago, I joined a team of Adobe Flash developers, and only then I realized how many routes a single coding task can take. We all have different approaches on coding and with this in mind, I felt the need to find a standardized way of developing Adobe Flash based websites / applications.

Last year, after a lot of online research on Actionscript frameworks, I found PureMVC to be the most stable, mature and — most importantly — well documented.

Kicking the tyres.

Before having other team members sharing my opinion, I had to try it myself and apply all the concept on a real project.

My first approach on this design pattern — by the time of publishing this article — is still to be available online. It’s nothing too fancy, but what’s on focus here, is the code holding the pieces together. It’s a structure built to support three websites with similar content for Casinos de Angola. Two websites are on an ongoing approval process, while the third is still to be designed.

“If anything can go wrong, it will.”

Having little to no experience using the MVC pattern, and a deadline to meet, it was a risky choice to make. But still, I opted to take this road. And so — validating the aforementioned Murphy’s Law — I failed the initial deadline.

The development process took waaaaaay longer than I expected. Not because there was a lot to code, but because there was a lot to learn in order to get a solid ground to start building with the chosen architecture.
A big learning curve of concepts before getting into any real coding is a bummer.

Happier programming.

What do you think about the idea? Sounds good, right? It feels even better!
The framework enables a loose coupling between resources allowing an easy development of really project independent components. Maybe this is geek / coder talk, but it feels a more Human-like communication between abstract project resources. Bare this in mind: the notifications are a bliss to work with!

Being an avid follower of the Don’t Repeat Yourself principle and a control freak for logical organization and standardization I chose to implement a Convention Over Configuration paradigm by specifying the website structure / layout in a single XML (Model) file.

As most developers, if I can avoid extra work, by automating processes, I do. Better yet: if I can avoid starting a new project from scratch, and just re-factor 10-15% code of a previous one, I SURE do. And that’s what happened. Having the website contents (Model/Proxies) automating the layout (View), only a few bits of the business logic (Mediators) had to be changed. Now THIS is (planned) code reuse!

Wrapping up…

“The concept of PureMVC may make the best of us shy away, but once you’ve got your head around the bare fundamentals, you’ll soon be flying your way around it.” — Ahmed Nuaman said it on the first tutorial on PureMVC I’ve read, and I could not agree more (though I’m still learning the flying part).

I’m currently — at the time I started writing this article — finishing the development of two video players with similar functionalities, and everything is running smoother and faster. The first player took around 7 hours to complete. The second one? 45 minutes!

One of the biggest conclusions I found with this road I took was that allowing myself to fail, brought an enormous bandwagon of knowledge and rewarding experience. Only by trying harder and harder every now and then, and subsequently failing a lot of those times, you will broaden your comfort zone and therefore your horizons.

Maybe there’s an influence here from the OFFF’s 2009 edition theme: “Fail Gracefully” and the “This isn’t flying, this is falling with style” quote from Toy Story.

Want to learn more about AS3 on PureMVC?

Follows a list of articles / tutorials / books I’ve read, that I think are important for anyone that would like to learn more on the subject:

I’ll be keeping this list updated with new articles / tutorials / books once I find and read them.

Any feedback?

Do you use PureMVC or have tried it? Like it? Hate it? Maybe another framework?
I would love to hear your opinions and to know whether or not I should go for a “Round Two” article on the PureMVC subject.
Your feedback will be much appreciated!

Photo by Jean Scheijen.