Oct
10

Mate examples: #11 Mediator (or Passive View)

Mate examples: #11 Mediator (or Passive View)

This blog post is related to My LFPUG Presentation about Mate blog post (I know, it was 3 months ago, it’s a shame but I also must work for a living).

If you haven’t done it yet you should have a look first at our previous examples: #1, #2, #3, #4, #5, #6, #7, #8, #9 and #10.

In our previous example we’ve studied a simple implementation of the Presentation Pattern. In this configuration, the View has a reference to its presentation model (or at least to its interface). But what if you want it to be the other way around? The view exists for itself and the model is the one who has a reference to the view. This approach definitely is a prime candidate if you want to use views generated in Flash Catalyst then synchronised with Flash Builder with CatalystBuilderSync. You can easily modify your views without affecting the logic whatsoever. The view is dumb or passive as explained in this other article by Paul Williams. It’s also one of the patterns used in PureMVC, called Mediator and we will keep the name here. So, how is it possible with Mate?

Let’s have a look (source is available by right-clicking on the demo after launching it):

Mate example

#11 Mediator (a la PureMVC) (click to Launch)

Continue Reading…

Aug
5

Mate examples: #10 Presentation Model

Mate examples: #10 Presentation Model

This blog post is related to My LFPUG Presentation about Mate blog post.

If you haven’t done it yet you should have a look first at our previous examples: #1, #2, #3, #4, #5, #6, #7, #8, and #9.

Today we’re going to put aside our (I know: boooring) counters. We will come back to them in a couple of posts for the great finale: Mate and versioned applications.
But for now I wanted to illustrate a really good practice with Mate (and in general): the Presentation Model pattern. For those who want to know more about the Presentation Model, have a look at Paul Williams great article. Basically, the idea is to keep the view as simple as possible, separating all the logic in a dedicated class. That way, Mate communicates with the presentation model class and not directly with the view, the latter being updated via data binding. In this configuration, the view’s only concern is its own elements and its only dependency is its model.

Let’s have a look at our very simple demo (source is available by right-clicking on the demo after launching it):

Mate example

#10 Presentation Model (click to Launch)

Continue Reading…

Aug
0

Mate examples: #9 Modules Example (pt 2)

Mate examples: #9 Modules Example (pt 2)

This blog post is related to My LFPUG Presentation about Mate blog post.

This is the ninth of a series of gradually more complex examples on how to use Mate. If you haven’t done it yet you should have a look first at our previous examples: #1, #2, #3, #4, #5, #6, #7, and #8.

By now, you should reasonably be up to speed so I’m going to speed up as well and throw examples more regularly but with less explanations (it takes some time that I don’t exactly have those days). If you really don’t get it though don’t hesitate to ask for further explanations in the comments.

In the previous example, we started to see how to use Mate with Modules but the main application was still keeping references to the module’s classes.

This example push decoupling a bit further (source is available by right-clicking on the demo after launching it):

Mate example

#9 Modules Example (pt 2) (click to Launch)

Continue Reading…

Aug
2

Mate examples: #8 Modules Example (pt 1)

Mate examples: #8 Modules Example (pt 1)

This blog post is related to My LFPUG Presentation about Mate blog post.

This is the eigth of a series of gradually more complex examples on how to use Mate. If you haven’t done it yet you should have a look first at our previous examples: #1, #2, #3, #4, #5, #6, and #7.

In our two previous examples, we saw how easy it was to handle communication between the application and its subcomponents, without mix-up between events intended to be listened by the whole application and events required only at the subcomponent level. But how would Mate hold up with with even looser subcomponents, of the kind that are loaded on demand and are not a concrete part of our main application, namely Modules?

I’m sure you know already it holds up pretty well, but let’s see how it does that:

Mate example

#8 Modules Example (pt 1) (click to Launch)

Continue Reading…

Aug
0

Mate examples: #7 Reset Countdown (pt 2)

Mate examples: #7 Reset Countdown (pt 2)

This blog post is related to My LFPUG Presentation about Mate blog post.

This is the seventh of a series of gradually more complex examples on how to use Mate. If you haven’t done it yet you should have a look first at our previous examples: #1, #2, #3, #4, #5, and #6.

In the previous example, we added a reset countdown which sets all the counters to 0 when the countdown is off. But it’s a bit of a pain this unstoppable countdown. It would be cool to add a start/stop button, wouldn’t it?

OK, let’s do it (source is available by right-clicking on the demo after launching it):

Mate example

#7 Reset Countdown (pt 2) (click to Launch)

Continue Reading…

Aug
0

Mate examples: #6 Reset Countdown (pt 1)

Mate examples: #6 Reset Countdown (pt 1)

This blog post is related to My LFPUG Presentation about Mate blog post.

This is the sixth of a series of gradually more complex examples on how to use Mate. If you haven’t done it yet you should have a look first at our previous examples: #1, #2, #3, #4 and #5.

Today we’re going to add another useless functionality to our already useless application: a reset countdown. It’s a timer that resets all the counters when it reaches 0. The point here is to illustrate the communication (other than using data binding) between a manager and the rest of the application.

Here is the demo (source is available by right-clicking on the demo after launching it):

Mate example

#6 Reset Countdown (part 1) (click to Launch)

As you can see, it’s pretty much the same application as before (visually speaking) except that there’s now a countdown showing up next to the MainView title. When it reaches 0 all your amounts, subAmounts and globalAmounts are reset to 0.

Continue Reading…

Aug
0

Mate examples: #5 LocalEventMap

Mate examples: #5 LocalEventMap

This blog post is related to My LFPUG Presentation about Mate blog post.

This is the fifth of a series of gradually more complex examples on how to use Mate. If you haven’t done it yet you should have a look first at our previous examples: #1, #2, #3 and #4.

In the previous example, we added the capability to add/remove counters to the Tile component dynamically. Now let’s imagine that each counter is now embedding two subcounters, each one being capable of interacting with the other, but without affecting the subcounters in other counters.

The demo should probably be clearer (source is available by right-clicking on the demo after launching it):

Mate example

#5 LocalEventMap (click to Launch)

Continue Reading…

Aug
0

Mate examples: #4 Counters created dynamically

Mate examples: #4 Counters created dynamically

This blog post is related to My LFPUG Presentation about Mate blog post.

This is the fourth of a series of gradually more complex examples on how to use Mate. If you haven’t done it yet you should have a look first at our previous examples: #1, #2 and #3.

In the previous example, we manually added four counters to a Tile component. Let’s now add/remove those counters dynamically.

But let’s have a look at the demo first (source is available by right-clicking on the demo after launching it):

Mate example

#4 Counters created dynamically (click to Launch)

Continue Reading…

Aug
0

Mate examples: #3 Multiple Counters

Mate examples: #3 Multiple Counters

This blog post is related to My LFPUG Presentation about Mate blog post.

This is the third of a series of gradually more complex examples on how to use Mate. If you haven’t done it yet you should have a look first at our first example and at our second one.

And now let’s have a look on the demo (source is available by right-clicking on the demo after launching it):

Mate example

#3 Multiple Counters (click to Launch)

Continue Reading…

Aug
1

Mate examples: #2 Databinding and EventHandlers

Mate examples: #2 Databinding and EventHandlers

This blog post is related to My LFPUG Presentation about Mate blog post.

This is the second of a series of gradually more complex examples on how to use Mate. It’s still a fairly basic one and visually it looks just the same as our previous example.

But let’s first have a look on the demo (source is available by right-clicking on the demo after launching it):

Mate example

#2 Databinding and EventHandlers (click to Launch)

Continue Reading…