Enterprise Web Applications

Posts Tagged ‘framework’

I’ve just come to London yesterday and went straight to London Flash Platform User Group meeting. Gilles Guillemin presented Mate Framework (read Mate as “maté”) which is supposed to take over Adobe Cairngorm and PureMVC frameworks and be simpler than those. I personally feel that Mate Framework is not much different from other frameworks just because it’s trying to follow the same idea about Flash event mechanism being the best way to communicate inside any Flex application. But events were invented mainly for visual stuff, with all bubbling, cancelling and stages! That’s certainly true they work great for Flex framework itself but Flex is visual components framework, and frameworks we’re talking about are for so called “client backend” – a layer between visual components of your Flex application and server backend.
So here are my thoughts about the ideal Flex framework. I’ve organized it in action steps/considerations that would help you to create such framework.

12 steps

1. If you can use Adobe Flex framework, use it! You’d better create a component than anything else. You can reuse components later in other projects and The Reuse is the main divinity in software engineer’s pantheon.
2. What is missing in Flex framework is a thin but important layer between Flex components and server side (Java, PHP .Net etc). This is where our ideal framework can be useful.
3. “Write less do more” is the only thing that important about any framework (it should be true in a long run too). Theoretical principles like MVC, patterns etc are not so much important as this one.
4. Dependency injection/Inversion of Control pattern is the next best thing after sliced bread. If you have numerous objects in your application (and you do usually have them), you have to write code to make calls from one object to another (to couple them). Look up code could take up to 1/3 of your total code if you have many small routines. It also makes your code highly coupled and hence not very reusable. So something that could automate lookups is definitely should be in our ideal framework.
5. The framework should help you to work with asynchronous calls. Asynchronous calls are the way how Flash app communicates with server side. Usually you need to add event listener and remove it after you got response from the server. We need to get rid of it and let framework manage it.
6. Also about asynchronous calls, it’s usually needed to chain some asynchronous calls (to make next call only after previous call is executed with success, for example). Or you just want to execute some function after all asynchronous calls are executed (and don’t really care about the order of calls). In this case what you usually do is to write lots of event listeners just to manage this workflow and it becomes a mess very quickly. So our framework should help us with that too.
7. Debugging. Flex Builder (for example) has quite good debugger so our framework shouldn’t break it or have any unpredictable execution flow (which is usually the case when you overuse events)
8. Code auto completion. This is something that we’d like to be able to use too (to avoid all these typing mistakes)
9. Our view classes or MXMLs should be decoupled but not too much. You should be able to take a look at MXML file and see any data dependencies it needs. However, our view classes shouldn’t care about how to get these data.
10. Testability. It should be easy to test you classes using FlexUnit for example. Writing/executing tests seems to be one the most important thing for bug free software.
11. We should use ActionScript3 language and not just copy Java idioms to ActionScript. It means to use functional objects and event listeners where Java uses anonymous classes and interfaces. The framework also should make good use of dynamic typing.
12. Performance: memory and speed. It should be the last point in this list as you need to take care of everything else before optimization. Premature optimization is the root of all evil!

Let’s see how Ctx Flex framework answers to these requirements.

Read more…

i personally don’t like bulky Cairngorm as it’s clearly designed with Java in mind. In my work I use own framework called Ctx (after the main class). This dependency injection (or IoC) style framework is ideal for dynamically typed language like ActionScript3.
There are many IoC frameworks but Ctx uses mainly closures and not events. For me, closures are better because using closures gives more clear workflow than passing events (i don’t even mention that you need to create multitude of event classes with such frameworks)
Please read introduction here

Source code and examples are available here http://code.google.com/p/ctx/