The Component :: Part 1 :: CSB
December 18th, 2008“We are not trying to apply MVC to component architecture since MVC was patterned after the Application domain. We are creating a pattern or more accurately, porting a pattern from the Application domain to the Component domain.”
Component (Model) | Skin (View) | Behavior (Controller)
Ever tried comparing an apple to an orange? They’re both fruit right? The apple and orange taste sweet and are colorful. If you try to describe both objects using the word ‘fruit’, you will not capture the essence of each.
We have the same thing happening with two other words of the same class, application and component. Same type of relationship right, ‘Is A’ fruit? No, these two objects are not in the same generalization, Component is an aggregation of Application.
- An Application is a domain to solve a larger network of problems, created by client’s needs.
- A Component is a domain to solve a larger network of problems, created by the application’s needs.
To many times we try to apply solutions to things that don’t apply to each other and in the end wonder why things don’t feel right or don’t even work. I’m specifically talking about the MVC (Model View Controller) design pattern in relationship to the Component.
Language, the articulation of thought and path to understanding the ‘object’. I have many years of experience with component development and books don’t teach what experience brings.
There are some that also would say breaking rules confuses people, I think it’s the rules that confuse people.
I have struggled with language for quite some time. When you try to explain things that are new, you either sound arrogant or full of yourself and someone tries to knock you down a peg.
I’m not trying to coin anything or declare an invention. I want the language and implementation of component development in Flex to be fun. So the first change to the MVC is the M (Model).
The M becomes C for Component. I have spent weeks agonizing about this decision since in ActionScript, the ‘component’ is tied to the display list, thus part of the View. But this is not really the case.
The display list is in the application’s domain, not the components. Remember about what I said above, domain specifics. In our new component architecture coming up (inspired greatly by sections of OpenFlux and Flex 4) is going to treat components like hierarchal data structures. This data structure parent or container IS the display list, the API and data are the Component instances.
Here are some one liners;
- The Application domain contracts the Component.
- The Component declares it’s public API and public data structure.
- The Skin observes Component through [Binding] or event handlers.
- The Behavior/s observes Component through event handler bindings.
There is a paradigm shift here where the behaviors of the once UIComponent needs to be abstracted off the Component class and into specific behavior classes. This is where the fun begins, since these behaviors can literally or figuratively be dragged onto a Component and reused or stacked.
I have introduced the idea of the behaviorManager that acts as an API service locater essentially delegating what is going on behaviorally within a Component. This also adds the ability to dynamically add API to component at runtime.
This is it for part 1, there is much more ahead since I am explaining the foundation of Teoti Graphix’s new component architecture.
All this will fit like a glove in Flex 3 and Flex 4. Currently I have fully implemented the FxButton and FxToggleButton using this new pattern, it’s awesome.
Ben Stucki, your awesome and thanks for a head start man.
Mike




