Why use a Flex framework like Cairngorm or Mate? - apache-flex

From what I understand a framework reduces complexity in areas that are common, like a log-in system. I use ASP.NET MVC at work and have done some work in Zend Framework but do not get how a framework helps with client side development. The reason ASP.NET MVC is used at work is for Unit Testing - does a Flex framework help with this too?
Please let me know why I should or should not use a framework with Flex?

The short answer is: it depends on the framework. :) My thoughts below:
Flex is itself a framework, and you can write reasonable applications without the need for any additional framework. Flash has a built-in event model that allows for bubbling events, so you can dispatch an event in a deeply-nested user interface component and have a listener higher up in the hierarchy that handles the event. The event handler can delegate to your model, which retrieves data from the server, and Flex's binding support can ensure that your views are appropriately updated from the model. I think it's important to understand that Flex applications can and should be written more or less according to that approach, and that any additional framework should help facilitate that approach, rather than providing its own way of doing things that ends up coupling you to the framework.
That being said, an extra framework that helps facilitate this approach can absolutely provide value. I would recommend Mate or Swiz because I think they achieve this goal. They don't try to reinvent the wheel or replace parts of the Flash / Flex APIs; instead they complement them. The dependency injection features make it much easier to provide data to your views, but without coupling them to any framework. There are a number of utilities available to make it easier to work with remote services. They also have a utils to facilitate testing or even persisting data in shared objects.
I have also worked with Cairngorm in the past and I would not recommend it. CG is notorious for requiring you to create a ton of classes that adhere to CG-specific APIs and requiring you to use many of their Singleton implementations which make your app brittle and hard to test in isolation. It is based on a number of J2EE patterns which fell out of favor in the Java community at least 5 years ago.
I've read a little about PureMVC and while I can't speak to its invasive nature, I think that reinventing the event model (called "notifications") is silly and couples you to their framework. Sure, you can say it "insulates" you from the Flash event model in case it changes, but I'd say the odds of PureMVC changing their notification model is far more likely than Adobe changing the event model. :)

If you've ever tried building a slightly large application, or one at all complex, things can quickly get out of control. I don't know how many projects I bailed on when I was first starting out because I didn't know patterns, or how to make parts of the system communicate without being tied to each other, or dependent on each other.
So, basically a framework is a collection of patterns put together. Theoretically, if you learn to follow the "rules" of a (tried and true) framework, your app will not get out of control to the point where you find yourself fixing one bug and causing two. I've been there and it's not fun.
I also found that by learning to use a framework you initially don't have to know so much about the patterns behind what you're doing. But before long you'll get a good handle on the patterns used and you'll be able to apply them in new situations or find a better pattern. So it's a good learning tool as well.
I'm sure people will have arguments against using frameworks -- this is just my experience. But if you become familiar with a few, you will likely find that one might be suitable for one project but not another.
As far as Flex frameworks, I personally like PureMVC. In all honesty the only other one I've given a good amount of time to is Cairngorm. But I like PureMVC because it feels right to me, but also it's generally not dependent on so much on the built-in Actionscript classes. For example, it uses it's own notification system. So if the notifications change in Flex, they'll still work in your PureMVC app. Also, the creator Cliff is super helpful in his forums, and he's really passionate about it. And the documentation is great.
I recommend coming up with a super basic app, and building it without any frameworks, then again with a couple others. You don't have to finish the app, but just get a feel for what's behind the frameworks.

You may find value in using a framework if:
You work in a team environment and want to be sure everyone uses the same approach
You have a large, sophisticated app and want to communicate effectively between parts of the app
You want to be able to hire additional programmers and have them be productive quickly
You want to ensure your application is built with a proven architecture
You want to leverage the knowledge of design patterns and solutions that are known to work well
You want to simplify a complex application
Here's a great article on Flex frameworks.
Flex Framework Comparison
And, I agree with the conclusion...Mate is a great Flex Framework.
Another interesting framework not mentioned in this article is Spicefactory's Parsley.

I use PureMVC (which is an MVC-framework for Flex) for my larger applications. Like 99miles stated, it depends on the application size.
If you just have to make a (relatively) small tool/application, you can get it going with just Flex. But if you want to create a large, complex application a Framework might come in handy.
The main reason I use PureMVC in Flex is because of the Model-View-Controller architecture. This separates the presentation layer from the business layer and works a lot with events and notifications. This gives you a lot of control in creating reusable classes/controls in Flex in a relatively simple way.
As I said before, for a small tool/app/website I wouldn't recommend using a framework, because in that case it might be to time consuming and complex. But for the larger applications, frameworks are quite handy.
More information on the MVC architecture can be found here.
Hope this helps :)

Related

What does a web designer need to migrate to Flex quickly?

What does a web designer need to migrate to Flex quickly?
A: tell me how I can get good fast
B: tell me why it would be unrealistic to learn Flex quickly
I want here both sides of it. Maybe web designers are not qualified, I'd
honestly like to know what it would take.
Thanks,
TELL ME WHAT I NEED
• Projects I need to complete in Flex
• Tutorials
• Key concepts
• Other technologies in a nutshell (webservices, SOAP, AJAX, HTML5 etc.)
MY SKILLS
• I code JavaScript (including HTML, CSS, XML, not much AJAX)
• Flash (hand code ActionScript 3.0 in classes, reasonable OPP skills)
• I'm a designer 'no computer science degree'
This Flex reference should include everything needed for beginning Adobe Flash Builder 4
To be honest, the tenor of your post is a bit irritating. Nothing worth doing comes easily or without some level of work. "How can I get good fast?" implies you either don't have time or don't possess patience to do things right. I doubt that's the case, however, and thus here are a few thoughts to your questions/bullet points:
A: tell me how I can get good fast
I don't know what you know, and thus cannot tell you how long it will take you to become a solid Flex developer. If you want to get good, you'll probably need at least some time; if you want to be fast, you can pick Flex up rather quickly, and your application may end up a buggy mess. Depending on your definition of "fast" (and what you already know, of which, as I've said, I'm completely ignorant), you'll probably have to take your pick between the two.
Growth in any area usually comes with experience, instruction from superiors, and learning from ones' mistakes. Getting "good" quickly is a concept which doesn't take these into account.
Your knowledge of Javascript, CSS, and design will certainly help, and I don't want to denigrate your current experience. Seven years of design is outstanding and a great gateway to Flex. Those skills, however, likely came with time and effort, and you should expect the same with most new technologies.
B: tell me why it would be unrealistic to learn Flex quickly
Of course you can learn Flex quickly. I picked it up in a few days, and have spent the last 2 years of my life writing Flex applications full-time. I consider myself well past proficient, and I still have quite a bit to learn. The basics aren't terribly difficult (esp. since you have ActionScript experience). Learning enough to be good, however, creates an explosion of new material to cover. Consider these questions:
Do you know how to architect a web application? Not just assembling a quick and dirty web-page with a few basic controls -- do you know how to build a full-fledged web application which is extensible, scalable, and robust in its communication with a remote data server?
Are you working with established data servers, or do you have to implement your own?
Do you know how to manage large data sets efficiently?
Do you know solid software design/development techniques and principles (DRY, YAGNI, KISS) and how to implement them in your code?
If you can't answer these questions (or answer them negatively), you probably have a way to go. If you can answer them positively, you're at least on the right track. There's still a plethora of things to know about Flex (some listed below), and each one will take some time to pick up.
• Projects I need to complete in Flex
This question is a bit vague. If you're referring to tutorials, you're repeating yourself (see your next bullet point). If you're asking what applications will facilitate writing Flex apps (e.g. FlashBuilder 4), you haven't done enough homework. If you're asking what programs we think you should write, you're asking the wrong people. See my next point...
• Tutorials
There are many tutorials for Flex development. Start with a basic Hello World program and add simple features to the page (e.g. user controls, multiple MXML and ActionScript files, packages, styles, etc.). You said you're a Javascript developer with HTML and CSS: why not attempt to rewrite one of your previous applications in Flex?
We don't know what topics you need to cover because we don't necessarily know what you'll be doing in Flex. If you never plan on performing HTTP requests, you probably don't need to learn this functionality (at least not immediately). If you will never work with server-side notifications to your app, BlazeDS and LiveCycle Data Services might not be important.
• Key concepts
Man, where to start? Data binding, Code behind patterns, MXML vs ActionScript, Flex Skinning, working with XML, MVC frameworks, the list goes on. No list of "key concepts" is going to make you good fast.
• Other technologies in a nutshell
(webservices, SOAP, AJAX, HTML5 etc.)
Here are a few things you might want investigate, depending on your needs:
BlazeDS
LiveCycle Data Services
Flex and HTTP
Asynchronous Requests in Flex
Mobile Application Development
My recommendation is to start with the basics, and see what you're up against. Build a "Hello world" app and extend it to include various other features. Then assess what you hope to build with Flex, and how you expect to retrieve data from a back-end server. These two points will help you decide what you'll need to learn next. From there you can research each new topic you're trying to address and how to do it correctly.

Flex Framework vs. Micro-Architecture

I'm in the process of choosing a framework for my flex development, and one of the questions that was asked about a framework was "is this a framework or a micro-architecture"?
Can someone clarify what's the difference?
What exactly is a framework, and when can we start calling what we have a framework? I work with FlexBuilder3 (now called FlashBuilder4) and have a lot of standard things that I do for almost all projects, and components that I created for easy re-use. Some are very very small, but the benefit of a 1-liner has been immense for me instead of repeating the code over and over. So in the framework/micro-architecture scheme, can I say that these are my internal in-house framework or are they part of a micro-architecture?
Trying to understand this topic better.
a framework is a library. it is the complement of component sets (or component libraries), which are also libraries. while component sets provide functionality (encapsulated in components), a framework provides architecture. so when using a component, you create the architecture, which embeds this component to use its functionality by making explicit calls through its interface. when using a framework, you actually provide the functionality, which is then called by the framework. this is called inversion of control, which basically leads to low coupling through dependency inversion.
Flex is both a framework as well as a component set. There is only little seperation between both in Flex, which is due to the fact that the Flex framework uses a hell lot of inheritance. Also, Flex provides only little framework features to the developer, but more to the Flex components themselves. That's why there is Cairngorm, PureMVC and many other frameworks on top of Flex.
From what you say, I'd call your library a component set. I know the word framework is very hip at the moment, but you shouldn't join the league of the many people totally misusing it.
Oh, and the term "micro-architecture" designates the internal architecture of a processor. I think framework actually is the word you were looking for.

The best Flex Framework you have used so far

I have been seeing some Flex Frameworks, but would like to ask to the programmers and Architects down here on which has suited best in your application.
Cairngorm
Pure MVC
Mate Framework
Custom One.
After using, in turn, all three of frameworks you listed, I can easily conclude that Mate is by far the superior framework. Of course, that's only my opinion and determining what makes a framework superior differs depending on your requirements.
To me, Mate's most appealing feature is how well it separates the different tiers of your application. After becoming familiar with it, I could never go back to using a framework that makes extensive use of global-state "Singletons" (Cairngorm, PureMVC).
However, Mate can probably be a bit difficult getting started with as the documentation is still a bit lacking and outdated, making it hard to know where to find the newest information. Some of the best practices and approaches that have been ironed out are to be found in the Mate forums, requiring some digging through posts. One of the most active users on that forum, Theo, has written a very good summary on the benefits of Mate in the following post:
Flex MVC Frameworks
PureMVC.... I like to have control and not relying on data binding... also since its been ported in different languages it has more value in my book than just a Flex only framework. Overall any MVC architecture is a plus in my book and it comes down to personal coding style/preference.
Cairngorm, and when I can't use Cairngorm (say, when using Flash CS3), I will simulate it (and it is really easy to duplicate conceptually). It is easy to set up, stupid simple, lightweight, and fast. If done correctly, it also forces a VERY clear separation of form and content. It fits in brilliantly with the native Flex classes and exploints data binding to the fullest. Of course, this might have something to do with the fact that it is the standard which Adobe explicitly endorses. Further, it is by far the most popular, which means if you need other people to be brought in and work on your projects, it will be far easier to find people who know Cairngorm than people who know the alternatives.
I find PureMVC incredibly bloated, non-ActionScript intuitive, and generally useless unless you work in a 99% Java company that does a very small amount of work with Flex and you want to have both use the same system.
I don't know anything about the rest.

whats an ideal candidate for asp.net mvc

is there any particular website that would make sense to use MVC versus webforms.
what would be the decision process in deciding between these options?
There is a lot of enthusiasm around MVC right now, but if you are starting a new dev project right now I'd still recommend that you carefully consider before jumping on the MVC train just yet.
For most dev teams on any non-trivial project, there are some serious considerations. Here are the ones I find most relevant:
MVC requires much more skill from your developers. They will need significant expertise in the inner workings of HTML/CSS as well as a good understanding of how HTTP works. For the client side code they will need strong javascript and JQuery skills, and on the server side an advanced grasp of OO principals. And if you plan to get the most from MVC, experience with unit testing and mocking frameworks too.
The MVC 1.x framework currently doesn't get much in the way of RAD features from Visual Studio. You get a text editor and intellisense, but that's about it. No wizards, no drag-n-drop components, no property editors, etc. While this isn't really that bad, it does often mean that building non-trivial UIs will take significantly longer, especially for less experienced developers.
MVC is very new, and so code samples, tutorials, and sample apps are very hard to come by and tend to be very limited in scope. Documentation is also a bit thin at present.
Perhaps the biggest drawback to the MVC framework is the lack of an established and mature 3rd party market around it. With web forms there are tons of very advanced UI suites and components on the market and tons of open source projects you can borrow from.
For many apps, especially business apps the lack of 3rd party reporting, charting, and advaned grid controls for the MVC framework alone should be a major concern.
MVC is fantastic, and I highly recommend it if you are in a position where you can use it. But there are real costs and risks for any significantly complex project that may keep you on web forms for a while longer.
I do expect that the next major version of MVC will probably address many of those issues, especially with the lack of RAD features. I also expect that the enthusiasm around MVC will bring a lot of 3rd party support to the platform too. But it will take some time for all that to get well established.
I wouldn't say a type of website would be better for either to but more or less the needs of a website.
If you need a website that's can be thrown together very quick without a large amount of code and you don't care about HTML markup. Than WebForms is the way to go.
If you're a control freak and you want control over everything that's happening and the markup being generated. Than MVC is probably for you.
MVC is less of an abstraction of the HTTP model meaning a lot less is done for you. It doesn't hold state like WebForms' ViewState.
I spent the last 4 weeks reading the available material on MVC and doing the various videos and tutorials. Today I started working on an actual application (with a client awaiting to see results some time soon). I agree with the previous answers (an awful lot to learn, many many new concepts, little in lieu of 3rd party components). Still I am glad I have spent the time learning mvc.
- You have to overcome your fear of row html/css/jscript which are hidden with webforms. It takes time to get used to the html tags. Once you do you will find out about the possibilities available. You will unlikely miss tags.
- If you have no experience using unit tests, then I think that mvc provides for a great introduction into the possibilities that come with unit testing.
- OO is much more present and "obvious" within mvc.
- Separation of concerns is possible and natural. You will not miss mixing gui and business logic in an aspx.cs file.
- No more page_load (and the n different stages). If you never quite liked asp.net's databinding, you will love mvc. I am happy not to have to do it ever again!
Cons:
- It is slow. At the beginning it is very slow. Things that take little time in webforms, can take a lot of time with mvc.
- Not having pages any longer is also a massive change. But once you "internalize" this (time...), you will not miss the pages.
- An O/R Mappers is also needed. One more thing to learn.
- There is a lot to learn and get used to, should you be interested in getting the most out of the framework. MVC is only half-mvc without unit testing. Unit testing without a mocking framework is not really possible, so you must learn that too. By the time you think you are half-way through with unit testing, you see the need to automate parts of your work, nant must be learned as well. It is just endless.... But again, once you start using these technologies you will wonder how you ever managed without.
The decision process for me is pretty simple. All new development will be done with ASP.NET MVC. Existing sites that need minor modifications will continue to be WebForms. Existing sites that need major modifications will be candidates to move to MVC.
The basic reason that I'm making the switch has to do with testability and design. IMO MVC web sites are significantly more testable. I can test everything but the view logic with unit tests and, by using and testing HtmlHelper extensions I can even test a fair amount of view logic. With WebForms I had to jump through lots of hoops to test codebehind and as a result left a lot of the app for manual testing.
I also feel that the architecture is simply better from a design standpoint. Because of the clear separation of concerns it's less tempting to insert business logic in the wrong place (e.g., the view). It makes conceptualizing and understanding the application much easier. I'm also able to reuse even view code with less effort because I don't have extraneous bits of logic from other layers hanging around to get in the way.
The only real downside I see at present is that it's not as mature and you don't already have as many reusable components built for it. I expect that to change, though, over time. Also, even though it is possible to intermix MVC with WebForms, I don't see retrofitting existing apps as a viable alternative unless there is significant other work to be done. Again, just my opinion, but I would rather start from scratch with MVC than try and get an existing app to work with it. I suppose it would depend on the size of the app, but anything with any significant number of pages is going to have a lot of routing exceptions.

Flex MVC Frameworks [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm currently using and enjoying using the Flex MVC framework PureMVC. I have heard some good things about Cairngorm, which is supported by Adobe and has first-to-market momentum. And there is a new player called Mate, which has a good deal of buzz.
Has anyone tried two or three of these frameworks and formed an opinion?
Thanks!
Mate is my pick. The first and foremost reason is that it is completely unobtrusive. My application code has no dependencies on the framework, it is highly decoupled, reusable and testable.
One of the nicest features of Mate is the declarative configuration, essentially you wire up your application in using tags in what is called an event map -- basically a list of events that your application generates, and what actions to take when they occur. The event map gives a good overview of what your application does. Mate uses Flex' own event mechanism, it does not invent its own like most other frameworks. You can dispatch an event from anywhere in the view hierarchy and have it bubble up to the framework automatically, instead of having to have a direct line, like Cairngorms CairngormEventDispatcher or PureMVC's notification system.
Mate also uses a form of dependency injection (leveraging bindings) that makes it possible to connect your models to your views without either one knowing about the other. This is probably the most powerful feature of the framework.
In my view none of the other Flex application frameworks come anywhere near Mate. However, these are the contenders and why I consider them to be less useful:
PureMVC actively denies you many of the benefits of Flex (for example bindings and event bubbling) in order for the framework to be portable -- a doubious goal in my view. It is also over-engineered, and as invasive as they come. Every single part of your application depends on the framework. However, PureMVC isn't terrible, just not a very good fit for Flex. An alternative is FlexMVCS, an effort to make PureMVC more suitable for Flex (unfortunately there's no documentation yet, just source).
Cairngorm is a bundle of anti-patterns that lead to applications that are tightly coupled to global variables. Nuff said (but if you're interested, here are some more of my thoughts, and here too).
Swiz is a framework inspired by the Spring framework for Java and Cairngorm (trying to make up for the worst parts of the latter). It provides a dependency injection container and uses metadata to enable auto-wiring of dependencies. It is interesting, but a little bizzare in that goes to such lengths to avoid the global variables of Cairngorm by using dependency injection but then uses a global variable for central event dispatching.
Those are the ones I've tried or researched. There are a few others that I've heard about, but none that I think are widely used. Mate and Swiz were both presented at the recent 360|Flex conference, and there are videos available (the Mate folks have instructions on how to watch them)
Check out Robotlegs.
"It provides the glue that your application needs to easily function in a decoupled way. Through the use of automated metadata based dependency injection Robotlegs removes boilerplate code in an application. By promoting loose coupling and avoiding the use of Singletons and statics in the framework Robotlegs can help you write code that is highly testable."
I've seen these kinds of discussions many many times. They usually start with WHICH Flex framework do you use. Not many people ask the question WHY do you even need to use any framework on top of Flex framework.
I'm not in favor of using any MVC framework (Cairngorm, PureMVC) in Flex code. Mate is a better candidate. At least it's simple to understand and is non intrusive. I prefer using enhanced components à la carte. We've created and open sourced a bunch of them (see clear.swc in the Clear Toolkit at http://sourceforge.net/projects/cleartoolkit/.
The first chapter of our upcoming O'Reilly book "Enterprise Development with Flex" has a detailed comparison of several Flex frameworks: http://my.safaribooksonline.com/9780596801465 .
We are currently working on a MVCS implementation in the Spring ActionScript framework. It uses the full power of the Inversion of Control container so you have centralized dependency management and are able to swap things easily. It is not very prescriptive in how you do things but provides you with a very flexible infrastructure.
If you are new to Spring ActionScript and MVCS, I have an introductory post at my blog: http://www.herrodius.com/blog/158
I am using (and recommend) Swiz framework. It's not as complex and PureMVC, but it gets the job done. Moreover, it's a IoC container, and I like IoC.
I never used Mate, so I can't comment on that. But I do recommend against Cairngorm. Cairngorm is said to be open source, but it's really not supported well by the community. It's release cycle is also slow. I've been waiting FOREVER for Navigation Library to come out of beta.
Bear in mind that Cairngorm is THE adobe sponsored framework, and now hosted on opensource.adobe.com. Also note that it's by far the most prolific amongst developers at the moment.
If you know Cairngorm and are looking for a job, you won't go far wrong.
Cairngorm is easy to use and well documented:
http://www.cairngormdocs.org/
I recommend the Cairngorm Diagram Explorer and the classic article about Cairngorm.
I was new to Flex when I learned Cairngorm but found it useful and easy to learn with the above.
MATE is the way to go.A framework which does what a framework should do.
De-coupled architecture
Simple
Small foot print
Efficiency
I kinda have my doubts on these MVC frameworks (Mate, Cairgnorm, etc...) with the way they implement event maps and event controllers, it reminds me too much of wxWidgets and other GUI toolkits of that sort.
However, would be really nice is if Flex or one of these MVC frameworks uses the Signal/Slots paradigm that Qt offers.
I recommend to use MATE for developing greats and complicated projects,like other frameworks, Mate addresses the common architectural concerns in Flex such as event handling, data binding, and asynchronous processing, but the most important goal is that it's only tag-based so it's very easy to use it in our Flex Applications.
Yes Mate is the best framework for flex. I have used in one application which had several revisions both in terms of GUI and back-end data service. I only needed to change my event-map every time there was any change.
Mate also has MockService implementation which makes testing easy not a mate's advantage but nice to have one.
You should design you own MVC "framework" based on your own needs. If you know a bit of design patterns, Flex has a lot to offer natively.
Best thing of designing your own MVC is that it can be a light weighted or complex as you need.
My experience with frameworks is that you basically have to write twice as much code than you would without using a framework. The good thing about frameworks is, that it forces you to work in a consistent way, but if you can work in a consistent way by making use of Design Patterns, best practices and common sense, I would suggest to stay away from frameworks.
Its very difficult to come to a conclusion about which framework is better than others. Depending on the nature and complexity of project and team members expertise & preference one may be more suitable than other in a given situation
I have compiled a list of Flex Frameworks with there brief descriptions and pointers to more information about them in this URL.
http://practicalflex.blogspot.com/2011/08/list-of-adobe-flex-tools-frameworks.html
the url may be helpful for anyone looking for evaluating a Flex framework for his/her project.
After evaluating many most of the Flex frameworks I found the Swiz framework most simpler and easy to get started with for a new developer. Hence it ensures easy maintainability & extensiblity of your application.
I have worked on cairngorm and mate frameworks. I started with cairngorm framework. It is good to work but difficult to understand in the beginning. It handles event dispatching cleverly. You can dispatch events from classes itself and it will be taken care of by the framework wired command classes. There is single repository for storing the data, so easy to handle the data. It is a singleton class. Once you get a hold of the framework, work is easier.
Mate on other hand is tag based framework. It is an event driven framework, so all events are handled in the eventmap file. It does event listening, property injection, and many other things from this class itself. You can dispatch events from the classes by passing it the instance of framework event dispatcher. You don't have to use singleton class like cairngorm in this. You can bind property in a class to views using directly using property injection so no need to use any singleton class. In mate all the classes and view are free from framework code, so it is decoupled framework. It is easy to move components from one place to other.

Resources