Pages

Sunday, March 11, 2012

PureMVC architecture for ActionScript 3

Recently, I took up a task to make my flash games more structured and implement the idea of code reuse. And to make the code generic with all the above qualities, I stumbled upon a framework called PureMVC which claims that using this framework, one can code at speed of thought. And in this post, I am going to justify this claim. This post will also tell about my experience in using PureMVC and why you should/shouldn't adopt it.

So, MVC stands for Model, View and Controller and the basic view of this framework is to divide the code into these three categories. Model has all the data related functions. View is the frontend i.e. contains visual elements and finally the controller is the link which controls the flow between model and view.

There are not enough resources or examples for a beginner to feel comfortable in making flash games in PureMVC in the beginning. I also learnt this framework using examples of Flex. But I assure you, that once you adopt this, life is gonna be easy for you :)

This is the best tutorial I have come seen on net: http://active.tutsplus.com/tutorials/workflow/understanding-the-puremvc-open-source-framework/
Book: A really nice book by Cliff Hall, creator of PureMVC http://shop.oreilly.com/product/0636920022459.do

So, initially it took me around some time to understand the flow but I advice you to start coding sample apps to get a feel of the framework. During my first try, I made a slideshow and it worked fine. The real essence of this framework is that data is separated from the visual components. So, if the frontend changes, the code of backend can still be reused. And this is what we are doing. Nikhil and Nirmal, two of the best guys in the team, made a generic backend which is being used in all our games. The game development time decreased substantially as now everyone codes within the framework and code reuse is happening.

So, code at speed of thought is an apt tagline but to reach this level, you need experience with the architecture and practice. And I surely advice to adopt it as speed of development will definitely increase !

No comments:

Post a Comment