Some say that Flex, due to it’s natural separation of interface and server, gives you the freedom from the tedium of working with MVC. Well, ok, I have an opinion on that like everything else…

Flex is awesome, and it does many things, but facilitating laziness is only a superficial benefit. Sure you may start building Flex apps with little to no design pattern influence and you may design a complex Flex application that is so removed from the server-side logic that you feel justified in your decision to use “the quicker, the better coding”. I have done this myself. But all of the original rules apply (but with built-in benefits).

The server will be isolated, that’s the nice thing about the Flash-Plugin as a delivery medium. But the Domain model living on the server is different than the M in MVC. The complexity of managing (C) how the interface (V) interacts with a session state (M) is nothing to overlook. You might say, “look at the current :: guest.booq :: sample application for example, it would be 50% of the time to write it without MVC or a framework.” Yes, originally it would, but going from one version to the next takes me less than 25% of the time it would normally take. This gives me more time for the important things like appearance (how’s that for superficial).

A Distributed Client like Flex, or Swing is naturally isolated from the server by it’s delivery mechanism. Please don’t make the mistake of believing this is the model-view separation you must employ for reuse and maintenance. You must encapsulate a small portion of your domain model into a session model of some sort. In standard web technologies this means having an isolated variable storage that you can access using a key. You take a piece of this session storage and you display and/or manipulate it in some way then you offer it back to the domain model for persistence. With distributed clients you usually hold the session model in the client. This is very different with a web page as the client, because having an xml structure of all your session model data in the HTML of the page wouldn’t make sense. Flex (or Flash in general) has a very capable OO architecture which is wonderful for caching and typing session data. So with this session model in the interface delivery mechanism you have the necessary parts (M and V) to do things the right way. Then, with some help from the smart ppl at Adobe, we can drop Cairngrom into the mix and come out with a very strong, time-tested way of producing RIAs utilizing Enterprise Design patterns.

MVC has been defined in so many places that I won’t do that here. I would like to talk about some Enterprise Design Patterns over the next few blog entries that are important to understand: Service Facade, Model Locator, Front Controller and the Command Pattern.

Leave a Reply