After attending an interesting session at Adobe MAX 2008 titled “The Flex Architecture Face-off”. At first I though the speakers (Yakov Fain, Chafic Kazoun, Todd Anderson, and Joshua Noble) were going to debate which framework was the best, you know, Cairngorm, PureMVC, Mate, and others. Initially the speaker surveyed which frameworks developers were using and not surprisingly, most were using Cairngorm (followed by PureMVC, then Mate). Then the speaker asked who wasn’t using a framework at all, and I was again surprised to see that about half of the audience wasn’t using any framework. You see I come from the thought that you need to have a framework in your box of tools to build most projects, they help coordinate group efforts, and they offer support. I had always just assumed that most Flex developers would be using some type of framework and that the flavor of framework was the only point of contention.
What made this particular session interesting was how the discussion turned into a debate, not about one framework versus another, but a debate about if you want to use a framework at all. The panel was mostly split. Chafic and Yakov were obviously not for using frameworks, while Todd and Joshua recommended using frameworks. The reason for using a framework varied. Some developers use them because it helps to coordinate the work when you have groups of developers, others use them because the client had stipulated that it was a “best” practice to have a framework. This make sense because you know that even though projects have a development life cycle, they will also have a maintenance life cycle. This means that the next group of developers coming in after you will need to go through your code and using a framework seems to facilitate this process.
This has my view since I started Flex. I enjoy using frameworks, even though some require extra work and setup, it just makes things easier to work in a group or hand off your work to others. It just feels comfortable to me, safe I would say. I would typically use Cairngorm for most application development, small and large because I am familiar with this framework and its widely used. If someone told me they were not using a framework, or I had to pick up code that was written without one from other developers, I would most likely cringe because that would require me to learn their way of doing things. This was also a big part of the debate, how to deal with handing projects off to others or working in groups if you don’t have a framework handy.
I remained skeptical and listened to how Chafic and Yakov explained how they handled these issues without using a framework. What may seem obvious, but might be overlooked, is that Flex is already itself a framework and most of the micro-architectures build upon the Flex framework using patterns (Mediator, Proxy, Command, etc.) and the built-in event dispatch system. If you know what you are doing with patterns and can build loosely coupled components, you can get by with out using a framework in your Flex application. You would essentially be building black boxes (components, modules) that know nothing about other components of the application. Communication would still take place through event dispatchers and listeners. You can also use a pattern to build communication for server communication and data retrieval. This is so reminiscent of my early Flash development days, when we didn’t really have a framework to build upon and we sort of invented our own communication system, mostly creating components with publicly exposed properties and methods.
Another argument for not using a framework, or perhaps a complaint about them, is that they require a lot of extra work and code setup time without really allowing any benefits for the developer. They are also traditionally hard to learn (some more than others). For example, Yakov said he didn’t like Cairngorm that much until he learned PureMVC (which he liked much less). I had the same feeling about PureMVC, it really feels like a heavy burden to create proxy and mediators over and over again, making all those delegates/commands much easier to create in Cairngorm. This made me think a bit about why I use a framework and what it might be like to not use one. I have done this on smaller applications where you might communicate with compiled SWC file that wraps an API like Flickr or Yahoo Maps, but I often try to put them into proper place within PureMVC or Cairngorm because I didn’t want them in my views.
I still get that feeling that when I don’t use a framework, I am somehow not being a responsible developer. When I started doing Flex, I really wanted to use patterns and best practices, using Cairngorm makes me feel like I am following some agreed upon conventions for building Flex applications. Not using one really makes me feel that the next person that looks at my code will be like “WTF is this spaghetti code?”. You know that developers often back bite the previous developers when they pick up a project. Cairngorm at least gives you some feeling that I am using standards that can be picked up by other developers. This is especially true when you want to train new developers or work with groups of people.
However, I think there is some value to building Flex applications without using a framework. I was persuaded by the methods Yakov and Chafik’s mentioned for developing without a micro-architecture framework and the small gleam of freedom that shined in their eyes when they said they don’t use one. Your development group can use an agreed upon convention for modular development and communication between components. Each person can build a smaller component that exposes public methods and broadcast events that other interested components can subscribe to. Also, rather than using a delegate/command to handle your business logic, you can create or wrapper API’s that handles the data calls and broadcast the events, much like adding the Flickr SWC file to your project. Some value for not using a framework might also come when you have to build an application or prototype fast, such as done within Agile Software Development. Jesse Warden just published a three-part series about his experience doing agile development and mentions how frameworks fit into this style. For more info, check out his Agile Chronicles series.
Abandoning your framework probably works best within small groups of developers that know each other and are confident in Flex. If you are not working in such a group or you are concerned that your own methodologies for Flex might not easily support maintenance after you are gone, its probably best to use a framework. The session ended up being more a question of using a framework at all, rather than debating which one is the best or most popular. What I would like to see is some examples by Yakov and Chafic on best practices for developing Flex applications in a group when not using a framework. I think its may be the way I go for my next personal project, but a few pointers would be great.
So, do any of you have an opinion about using a framework or not? Best practices applied when not using a framework? Examples? I would love to hear them.
I found another discussion about this topic from the FlexWizz blog article titled “Why I hate MVC”.
Todd Anderson also posted some of his thoughts about the panel discussion at MAX.
InsideRIA posted a complete review of frameworks with examples. They also ask “why use a framework at all?”