Mate - Introduction

(This is the first post in a short series on Mate.)

I like frameworks. I don't know if it's because my introduction to programming was from an OO perspective, so concepts like MVC and dependency injection make a lot of sense to me, or perhaps it's because I'm somewhat OCD and like to keep my code clean and organized. Or maybe it's simply because I'm lazy. Whatever the case, I have been a big fan of frameworks for some time. Be they off-the-shelf open source frameworks, or home-grown mish-mashes of code. Getting to know how a new framework operates is usually a daunting task. I learned a lot reading the documentation to Mach-II, but never ended up using that framework. Similarly, using the Arp framework for my first Flash desktop application (built using Zinc) was a great learning experience. I rarely build a ColdFusion application today without the help of ColdSpring and Transfer. When it comes to Flex, though, I hit a wall.

Flex is a different beast. The only way I can think to describe it is to say that it is more "enterprise-y" than I'm used to. Being a solo developer generally means that I don't take on enterprise-level jobs. Working with ActionScript 2.0 allowed me to solidify much of my OOP knowledge, but Flex asks for more. And it's a good thing, too, because it brings out the programmer inside. Because Flex itself is a "framework", the concept of using a "Flex framework" seems odd at first, especially while you are still learning by building single file applications. Even as you learn to add small, custom components, the idea sticks in your head that you don't need a framework; you're already using a ModelLocator, a makeshift Controller, and your Views are decoupled, relying on bindings to keep them updated. Eventually, though, you come to realize that, maybe, just maybe, you could use some help.

Enter Mate. From the same folks that brought you this blog's software, Mate is a tag-based, event-driven framework for Adobe Flex. While I'm still not quite sold on the benefits of the tag-driven part (it makes perfect sense for UI, but seems unnecessary for logic,) the event-driven aspect is fantastic. Like Flex itself, it makes you think about how you structure your application. By building your code around an implicit invocation model, you'll end up rethinking a lot of decisions, which can be frustrating at first, but rewarding in the end. In this type of software model, components of the system announce events, triggered by certain actions, such as a mouse click or a value change. The issuing component could care less (usually) what happens after the event is dispatched. Any interested parties (models, business logic, other views, etc.) make their interest in the particular event known to the system, and when it is broadcast, they are notified. Views then receive updates through bindings in the Model. In Mate, the EventMap, a non-visual MXML component, handles the listening part and executes a sequence of commands associated to each event.

In Part II, we'll go over the EventMap and migrating from ModelLocator to Managers. Part III will talk about dependency injection using the PropertyInjector and how to create reusable Views.

0 comments