KAPSID – Neko's Blog

Form Follows Function

Pure MVC – Framework

If i just waited another week I would have neglected this blog for a whole month. Half way through this period of posting drought there was a puny attempt to write about the basics of isometric graphics. This was aiming to create an ongoing posting chain which was supposed to result in the creation of my own isometric mapping engine. Instead it stranded in the drafts list of this blog.

My current situation requires me to push my interests further down the road of code abstraction. As a newbie in OOP development one quickly feels pretty darn smart reading about programming methods like ‘Factory’ or ‘MVC’.

“Hey, I’m cool. Coz my shit is super abstract, mega dynamic and incredibly maintainable. Who cares if yours rotates in 3D?”

Turns out this is only the tip of the ice berg ( german phrase ). Have a read at PureMVC.org and make sure you have a look at their MVC structure diagram. PureMVC is a pretty successful open source framework which exists for a vast range of programming languages like C#, Java, JavaScript, Python, PHP and of course AS2.0 & AS3.0. It comes in two versions: Single and Multi Core. Which, in a nutshell, means: Make a framework, that has been developed to handle a large project, capable of combining multiple large projects ( multi core ) and make it become humongous. This happens by applying “name spaces” to the modules which are likely to utilize the same naming convention. I have spent the whole day reading through PureMVC’s classes and slowly the nebula starts to thin out.

PureMVC works with another layer of abstraction. In fact it is two. Firstly Model, View, Controller become Singleton classes. They administrate proxies, mediators and commands which once have been multiple models, views or controllers. Mediators and proxies now sit in between Singleton Model, View and individually designed UIs and Data Objects. They are responsible for the uniform execution of processes like registration, notification and so forth, which connect to the frameworks actual functionality. Furthermore does the introduction of these additional elements secure lose coupling and is therefore good OOP practice. The second new thing is another Singleton class called Facade. Facade serves as entry point to the application and as global and ubiquitous reference point to Model, View, Controller and therefore to all proxies, mediators and commands. This way classes only need to reference Facade and don’t have to import other classes from all over the place. Facade is the only class that knows much about the MVC mechanic. All others need to stay as oblivious as possible.

Having played around with MVC a little bit, PureMVC has already answered some of my reoccurring questions. From what I can see so far it appears to be a very powerful tool, which once mastered could add clean structure and efficiency to ones code but also pose a serious overkill to many other, smaller projects.

Subsequently, my initial confusion turns into strong curiosity.

Please feel free to correct me on my quick and rather lose summary of PureMVC.
Cheers

Gabor

Filed under: Design Patterns