Seacoast ColdFusion Flex Group

NH Seacoast ColdFusion and Flex User Group

Matthew Teece

Pragmatic Application Architecture in Flex / AIR : 1

A common trend found in a quite a few of the Adobe Flex, AIR applications I have come across is the lack of a abstraction, hierarchy, or modularization. A not so common trend is a template or best practice around those three architectures; abstraction, hierarchy, or modularization.

For a small Flex / AIR application, it is a given that Flex allows for all of your code to be placed in the common src/myprojectname.mxml. If your code is short and sweet, merely looks at an RSS feed for example, or is an experiment. No problem.

However, in more complex applications, with hundreds to thousands of lines of code, controls, and behaviors; all in one single MXML project file, the ability to add to that code, refactor, test, debug etc. Becomes exponentially complex.

I have seen this too with Flash / Actionscript 2 & 3 and some designers, where as behaviors become more complex, and the code deeper and more nested, there seems to be no approach to encapsulation. Now I am not speaking for everyone here, there are those that do modularize, or encapsulate. I have seen great examples, some great encapsulation, but when it comes to Flex, I am seeing it as lending itself to that same paradigm.

It is easier to use, so in turn has the potential be even easier to make a mess of unwieldy, unreadable code.

I haven't found many articles, or books (thanks O'Reilly) that really dive into the 'Hey ! Let's actually start to architect a Flex / AIR application in a really modular way !'. To open the dialogue, I think I will start maybe a multi-post entry on a great way to approach the architecture and code using Flex, AIR, MXML, XML, components, and AS3 in nice encapsulated architecture, that is modularized (and scalability!).

More soon...

(ps. stop using com.example.org now. right now. thank you.)

Share 

Comment

You need to be a member of Seacoast ColdFusion Flex Group to add comments!

Join this Ning Network

Ken Dunnington Comment by Ken Dunnington on March 4, 2008 at 12:12pm
I'd also suggest checking out Model-Glue and Mach-II. MG is a very nice MVC framework that makes use of a strong event model, and ties in well with other frameworks like ColdSpring (IoC) and Transfer (ORM). OOP in CF has come a very, very long way.

But the point is that languages with low barriers to results (and I think CF and Flex both count, among many others) can be more easily abused. I think it's a symptom of "You CAN do it this way, but SHOULD you?" :)
Joshua Cyr Comment by Joshua Cyr on March 4, 2008 at 11:59am
Yea, you should take a look at the other MVC frameworks for CF as well. I just started working with ColdBox. Interesting thus far, and well supported/documented, etc.
Matthew Teece Comment by Matthew Teece on March 4, 2008 at 11:36am
Agreed I have done some Coldfusion work myself and it does not lend itself very nicely to OOP.

Some simpler methods in Coldfusion, mimicking the .NET C# code behind model, using a .cfmx view type page with a simple include to a .cfml page that has variable declaration, stored procedure calls etc. Is a step in the right direction for a larger project I have found.

One of the more convoluted methods in Coldfusion I have seen, and it is a bear, is Fuse Box. Although I am only familiar with an older version of Fuse Box (the newer versions seem a much better in MVC). However the one large index.cfm, with 5,000 lines of code. It is like one giant switch statement, that is totally unreadable. Or at least very difficult to follow from other Coldfusion files bound to it. Especially with variables of any sort, using params.

My goal is to get each flavor of what Flex offers (AS 3.0, MXML, and XML) into something nice and structured. Doing so is another matter. The MXML allows you to make other MXML files that can be called from other MXML files. For example a landing page that pulls in a login screen. So that has me somewhat worried though, as you could end up having 50 MXML files.

I really want to leverage AS3. It has come so far along, OOP, encapsulation, it is a great that they matured it so much. The class structure is great, you can make pure .as files as stand alone (no Flash 8 Pro or higher required). I really want to make that the core of anything I do.

Curious about Flex ANT tasks too (I use NANT in .NET) to automate building. As well as Unit Testing, which is difficult when it comes to Flash.
Ken Dunnington Comment by Ken Dunnington on March 4, 2008 at 10:34am
I think ColdFusion suffers from a similar problem. While, in my experience, the Flex framework actually lends itself more towards a component-oriented design, the flexibility it offers can be dangerous, in that a developer with little or no OOP background can create a working product using one gargantuan MXML file. Sometimes it's too easy for its own good. :)

I've seen (and produced!) this with ColdFusion apps as well. Massive PageControllers with way too many if/then statements... Scary stuff. I'm looking forward to your posts. I agree that there isn't enough architectural documentation out there for Flex. The LiveDocs section on custom components, while surprisingly good, isn't enough to help someone just getting started with OOP concepts.
Matthew Teece Comment by Matthew Teece on March 1, 2008 at 9:22pm
Early on in the Flex Beta's (1 & 2) I read about Cairngorm, but never used it.

I was at a small conference and one of the Adobe application demo's were built on design patterns used in Cairngorm, but not the framework itself.
Joshua Cyr Comment by Joshua Cyr on March 1, 2008 at 8:53pm
Hey Matthew, what is your experience with Caringorm? http://labs.adobe.com/wiki/index.php/Cairngorm

Badge

Loading…

© 2009   Created by Joshua Cyr on Ning.   Create a Ning Network!

Badges  |  Report an Issue  |  Privacy  |  Terms of Service