The Cairngorm Microarchitecture's Future and Cairngorm Code Generators
In my morning review of the MXNA I saw a couple of interesting posts related to the Cairngorm Miroarchitecture.
First off, if you didn't already know, Cairngorm 2.2.1 has been released. From what I understand from the Adobe Consulting team, Cairngorm 2.2.1 is now stable and will remain at this version for a while. And while you are looking at the new version, take a look at the fact that Adobe has split Cairgorm into two different flavors: Cairngorm and Cairngorm Enterprise. Basically, if you are going to be using LiveCycle Data Services (formerly Flex Data Services) you will want to use Cairngorm Enterprise, otherwise you should use Cairngrom that comes in a SWC library with a much smaller file size. It is my understanding that Adobe has also been pulling some of the framework code that is only needed for using LCDS out of the Flex Framework and adding it to the SWC for LCDS. Getting better organized is an awesome thing to do. Find out more about the other things Adobe is doing with the Flex Framework here.
Adobe Consulting's Steven Webster posted "So What's Happening Next with Cairngorm" where he makes light of everyone asking about how to pronounce "Cairngorm". (Cairngorm is the name of a mountain range in Steven Webster's homeland Scotland and is pronounced "cayre-n-gorm" (except that it sounds a whole lot better when it is said by a Scotsman). Steven also mentions that there is a lot of thinking going on about "the kind of architectures that evolve as you begin to leverage LiveCycle Data Services" (in this instance, leverage is pronounced "lee ver age" ;-), which Peter Martin, also with Adobe Consulting, presented at last week's MAX 2007. So that makes it obvious where the focus for Cairngorm is headed.
Later in the same post Steven mentions that the Adobe Consulting team has been looking at some Eclipse plug-ins to increase developers productivity when using Cairngorm. I am so totally for that it isn't even funny. Steven says it is coming, so I'll have to be patient.
Speaking of Wizards and code generation, Tim Buntel is asking about Wizards in relation to Flex Builder in his latest post. Hop by there to give him your opinion.
While I am waiting, I thought that I should mention two other projects focused on Cairngorm that we have been keeping an eye on: 1) Eric Feminella has the Cairngen, a Cairngorm code generator that allows for a quick set-up of the code for a Flex project that uses Cairngorm, and 2) Tyler Beck's Cairngorm Creator that also generates the start-up code but in a Flex application. Pretty neat.
Update: (2007-10-19): I wanted to update this post with more information that was provided by Ramsey in the comments (thanks for reading Ramsey) and wanted to bump them up to the post in case people are not reading the comments. To quote Ramsey:
Just thought I'd toss these 2 other tools for Cairngorm into the mix to see if anyone can get some help from them:
Cairngorm Flex Assistant - http://cairngormflex.sourceforge.net/
AS3VOGenerator - http://blog.everythingflex.com/category/as3vogenerator/
2513 Views
10 Questions About FlexUnit and Cairngorm
Since I have been struggling with FlexUnit in my "free time" over the past few weeks I was anticipating Wednesday night's AFFUG meeting featuring John Mason presenting Unit Testing and Test Driven Development (TDD) for Flex & ActionScript 3.0. John gave us a good overview of where unit testing came from and how it is applied to Flex and Actionscript. He also showed an example application that worked, created a couple of tests for it which promptly failed and then fixed the code.
[Leif's Note: If you want to skip the introduction to this entry, feel free to skip down to "1. Who is using FlexUnit?"]
What is FlexUnit, Anyway?
FlexUnit, which is based upon JUnit, is a framework that allows for unit testing with Flex applications. Wikipedia says that unit testing is "a procedure used to validate that individual units of source code are working properly." Ideally, a developer would create a unit test that tests a feature before beginning to program the feature. This process empowers the developer to fully understand the feature they have been assigned to create and to plan for all the potential problems that could occur with the feature. The end result is that the project would have a unit test to verify the feature is working and that all the unit tests could be run every time a build is created to verify that all features work. Unit testing is a fundamental part of test-driven development and continuous integration, concepts that I will not be discussing today but needed to mention.
So, What is Your Beef with FlexUnit?
The way John Mason presented it, FlexUnit seems very cut-and-dried simple until you consider two things: 1) Actionscript is/can be asynchronous and 2) we use the Cairngorm framework at Roundbox Global when we create applications in Flex. Also consider that it is likely that these two factors would be considered too advanced to be covered at any user group meeting that I could attend, may be too complex for a 55 minute session at MAX, and not many people are even talking about FlexUnit much less Cairngorm. Is there some vast conspiracy to keep this kind of information away from me?
Why is FlexUnit so Important?
FlexUnit is important because rich Internet applications (RIA) are complex. As a developer, I believe that it is my responsibility whenever possible to make certain that my code works well — not only should functions meet their requirements, but I should investigate that feature so that my code has as few bugs as possible, and that my code does not break other parts of the application. With the complexity of a modern RIA and the the larger teams needed to create these applications, this ideal is difficult to achieve. Developers need to utilize any tools available to reduce the stress of quality assurance (QA) departments (as well as the stress between development departments and QA departments) by eliminating defects in development. Unit testing is one of those tools.
With the size of the applications being built and the teams required to build them today, no company can afford to have seemingly endless cycles of our QA department finding things that developers should have thought of or found before committing their code. Developers must take responsibility for their work! They can not give excuses like "it wasn't in the wireframes", "I didn't think about that", "it's not my fault my code broke their code", or the classic "it works great on my machine" without impacting harshly on the whole team's deliverables, deadlines and work schedules. Ultimately, we all want to have a 40 hour work week.
What we are trying to do at Roundbox Global is establish a best practice of creating unit tests to establish a build's viability before handing the build off to QA for testing. Passing these unit tests should reduce the chance of QA receiving a build that, after hours of testing, is found to be invalid because of some flaw. We are also hoping to add some automated testing to our process in the near future as well.
So here are my questions to anyone who wishes to answer. Yes, there are more than ten questions. Consider them as ten groups of questions. Jump into the comments to let me know any facts or opinions that may help me and any readers out there. Hopefully I will be able to update this post with more details before the end of the month.
1. Who is using FlexUnit?
At Wednesday's event I got the impression that there were not that many developers already using FlexUnit. Are developers out in the wild using FlexUnit? Or are developers not doing any unit testing at all for Flex projects? I've heard that the folks at Universal Mind are using FlexUnit. Who else? And are they using FlexUnit with their over-all unit testing plan or just with Flex? And are they using continuous integration?
2. Who is Using FlexUnit with Cairngorm?
John asked the audience at Wednesday's event if they used the Cairngorm framework. Only a tiny minority raised their hands. You may already know how I feel about Cairngorm — it blows my mind when I hear about large projects that were not created using the Cairngorm framework. So, if a minority of people use Cairngorm and a minority of Cairngorm users use FlexUnit, where does that leave us? Considering that sites like FlexExamples have one or two entries daily, I'd call it a communication void.
3. Must I Change FlexUnit to Use Cairngorm with FlexUnit?
In my searches for FlexUnit information online I ran into several blog posts about using FlexUnit and Cairngorm. Each of the entries seem sincere, although somewhat incomplete, these post seem to say one thing: FlexUnit is not ready for Cairngorm. Must we make changes to the FlexUnit to get the asynchronous functionality necessary with Actionscript and Cairngorm? Could there be a good way to get the changes needed committed to the repository? Or are there issues with adding these modifications to FlexUnit?
4. Where are the example applications (using Cairngorm or not)?
Using FlexUnit is probably "no big duh" to a seasoned Java developer. But as John showed us Wednesday night, FlexUnit makes a lot of assumptions of users. For instance, did you know that test method names need to start with the word "test"? It's not just a naming convention, as we were shown last night, it's a requirement. So, for those of us who aren't seasoned Java developers with years of unit testing experience, where the heck are our FlexUnit examples? It would be nice to have some easy and complex examples of unit testing applied to something like the Flex Store (or the Flex Cairngorm Store, or the Flex Cairngorm ColdFusion Store). I'd do it myself (and may yet) but I am still getting my head around using FlexUnit.
Leif's note: I posted a few locations of FlexUnit examples in another blog post here.
5. What do we test with FlexUnit?
So what exactly do developers test with FlexUnit? I believe that we can completely test our connections to the back-end fairly well with FlexUnit — we can test that proper data is returned from the server using different types of data. But, without getting into an automated testing discussion, isn't there something more we can test? For instance, with Cairngorm, we can test Delegates. But shouldn't we take it a step further and test the Event, Command, and Delegate sequence? (I like to call that the ECD chain, by the way) Sure, making certain that the Delegate is working is important, but if you are using Cairngorm correctly you would never call a Delegate without invoking an entire ECD chain. And are developers testing for results of Delegates, or are they testing
6. What is the best way to use setUp and tearDown with Cairngorm?
As you may know, it is common best practice to use the setUp and tearDown methods for every test. When I use Cairngorm and I want to test a specific Delegate or ECD chain, often there are items that need to be set in the model for the Command to call the Delegate properly. Would it be all right for me to directly set things in my ModelLocator, i.e. without using an Event like these items would normally be set in the application? Same question goes for the tearDown.
7. What else are other developers using with FlexUnit?
Are there other "gotcha's" with FlexUnit that I don't know about? Seriously, no one is talking much about FlexUnit and the docs are minimal. Are developers modifying FlexUnit to work around problems or bugs? Are developers successfully using FlexUnit with Cruise Control?
8. Why is FlexUnit stuck at version .85?
Besides the changes to allow for the use of the Cairngorm framework, what functionality is missing from FlexUnit that has it stuck on version .85? What kind of effort will it take to get FlexUnit to a rock-solid 1.0 version? I realize that most of the owners of FlexUnit are either busy working on Flex 3, AIR or consulting for Adobe. But since I do not see a road map, I have no idea what is missing and how developers may assist them to reach this necessary goal. And while we are at it, when the heck is Cairngorm going to get the same open source treatment as FlexUnit? I love what you did to simplify Cairngorm in version 2.2!
9. What is next for FlexUnit?
Could there be more modifications necessary in FlexUnit to make it more compatible with the asynchronous nature of Actionscript? Are there new features in JUnit that need to be added to FlexUnit? Again, what is our roadmap?
10. Does Flex 3 take advantage of FlexUnit or Cairngorm?
With the upcoming release of Flex 3, will there be any new features around creating projects using Cairngorm or creating unit tests with FlexUnit? Flex Builder Wizards like Cairngen? Wouldn't it be great to point a Flex Builder Wizard at a folder of Delegates and have simple unit tests created for you? Mmmmm, goodness.
2981 Views
My Selected Sessions for Adobe MAX 2007
These are the Adobe MAX 2007 sessions I am chomping at the bit to see in no particular order.
XD: Prototyping Rich Internet Applications with Fireworks CS3
Best Practices for Developing with ActionScript 3.0
Building Accessible Applications with Flex
Building Stunning Flex Applications with Flex Builder and Creative Suite 3
Flash Player Cross-Domain Security
Introduction to LiveCycle Data Services for Flex Developers
Advanced LiveCycle Data Services for Flex Developers
Building Rich Internet Applications with Cairngorm and LiveCycle Data Services
Continuous Integration with Flex, FlexUnit, and Ant
Sneak Peak General Session (worth the price of admission)
Hope to see you there.
1242 Views
When is Cairngorm too much for a Flex 2 application?
Last week I ran into a great deal of resistance to using the Cairngorm Microarchitecture with a medium-sized Flex 2 application. The project itself was going to be separated into three applications: a login application, an administrative application and a user application. The admin and user apps had several screens and some fairly complex components on it. The back-end is Web Services-based. In my mind, this application is a true candidate for Cairngorm.
Now, I have to admit that the reasons given to describe the resistance seemed rather short-sighted and misinformed — "it's over-kill for an app this size" and "I hate having to go down three folders to get to the code." At least, those were the only complaints that were offered.
So, I thought this might be a good time to ask the question in this public forum and see what others may think: When does using the Cairgorm Microarchitecture make the most sense? Is Cairngorm only for the super-sized apps? Or does the best practice of using Cairngorm with anything bigger than an application that has two forms still make sense to Flex 2 developers?
What is the Cairngorm Microarchitecture?
To quote the Adobe Labs Wiki:
"The Cairngorm Microarchitecture is a lightweight yet prescriptive framework for rich Internet application (RIA) development.Cairngorm is an implementation of design patterns that the consultants at Adobe Consulting have successfully taken from enterprise software development (with technologies including J2EE and .NET) and applied rich Internet application development using Adobe Flex."
So, perhaps that doesn't make a lot of sense to an uninitiated developer. To put it more simply, Cairngorm allows for teams of developers to create code that provides clear separation of model, view, and control layers, is easily maintained, uses established design patterns that makes events — both within the application and between the application and server — easier to create and manage.
Surely, using Cairngorm would not be recommended for a one or two form application. But even so, there are good reasons to use Cairngorm.
Standardization of Folder Structure
Yes, when you finish setting up the Cairngorm Microarchitecture there ends up being a lot of folders. But isn't that one of the points for using any framework (not just Cairngorm) — a standardization of structure? When working in a team environment, establishing a file architecture is essential for efficient and maintainable coding. Sure, you can create your own framework, but look at Cairngorm's file structure; if it isn't very familiar then you haven't been developing for very long time — Cairngorm uses tried and true best practices found in Java and .Net frameworks.
Event Architecture
You may use the event architecture native to Flex 2.0 to create, dispatch and consume user gestures as well as communicate with the server. That is why that architecture exists. But the Cairngorm Microarchitecture expands this native functionality to assist the developer by encapsulating both user gestures and system-level events into one structure.
Cairngorm uses the Service to Worker design pattern, which is a combination of the Event Dispatcher design pattern, the CairngormEventDispatcher, and the Front Controller and View Helper design patterns. Yes, that is three design patterns being used together, which is not uncommon, and can be difficult for an inexperienced developer (and often experienced developers) to get their head around.
Ease of Maintenance
When working in a team environment, developing maintainable code can be a real challenge. Using a framework resolves a great deal of the challenge by establishing where specific types of files should be placed along with providing guidelines for development. The rest of the challenge comes from making certain that all the developers follow those guidelines.
The best example of how using the Cairngorm Microarchitecture makes maintenance easier is the "commands" folder. It's the folder where all the communication to the server happens. Suppose there was a change in the server-side code that makes it necessary for a change to be made with the command that calls that method on the server? Who can make that change? Well, anyone on your team. Basically anyone who has the most basic knowledge of Flex can find the folder, open the command file, make the change, recompile the application and test it.
In fact, I would recommend that team managers assign junior members of their teams to preform maintenance as a way for the junior members to become accoustomed to the Cairngorm Microarchitecture as well as to see what other coding guidelines have been established.
Back to the Question at Hand
If you are considering using, or in this case not using, the Cairngorm Microarchitecture, perhaps you should first take a look at Steven Webster's blog posting "Why I think you shouldn't use Cairgorm." Steven is one of the people that is responsible for Cairngorm from a time before he became an Adobe consultant. His advice is sound.
To answer my original question, Steven suggests you should count your user gestures:
"So what exactly do I mean here? I'm trying to measure the complexity of your application how many different things can the user do with your application, that merit some computation being performed on the client or server. Viewing all products in a catalogue is a use-case. Adding a product to a basket is a use-case. Deleting a product from a basket is another use-case. Taking the basket to the checkout is another use-case. Checking out is another use-case. Ad infinitum. If your application has several use-cases, then the organisation that Cairngorm will bring to your source-code becomes valuable."
So, if your use-cases total more than, say, two then you are building an application big enough to use Cairngorm. Of course, that comes from Steven, who has a biased opinion about Cairngorm, but with several enterprise-level applications deployed he has the experience to back that up. My experience tells me something more: if your use-cases total less than two, you aren't really building an application. You are building a form.
Further Cairngorm Reading
The Cairngorm framework is not something that you should enter into lightly, especially if you have never used a framework.
It would be a mistake for me to not mention Steven's five-part introduction to Cairngorm, written back when Cairngorm .99 was around, should be required reading for anyone who is starting to use Cairngorm. In fact, on the CFlex site, Tim Hoff said, "I read the entire article series front to back, probably 4 times, before everything sank in." I might go as far as suggesting that, if studying the sample application and documentation at Cairngormdocs.org doesn't get you on your way, perhaps it might be necessary to find a good counsultant or contractor to get your internal staff off on the right foot.
4673 Views

