FMP Tutorial: Visualizing Active Object
FMP is a very flexible programming model. You can use it as simple as injecting just a single active object into your existing application. You would be able to do so after read a few API docs. However, if you like to master FMP and unleash its full potential, you would be better able to effectively think in active object as if it is one of your native thought elements.
In this tutorial, I am going to introduce you a technique I used to adopt the concept of active object into my thought process. I cannot guarantee that it would work for you, but I believe it could inspire you to discover your own method and train your mind.
Figure 1: Visual Element of Active Object
I started by visualizing active object using a visual element as shown in the figure 1. The goal is not to implant the visual element into my mind. Indeed it just triggers some concepts I already have in my mind because of the similarity between the visual element and those preexisting concepts. As a result I do not create anything new in my mind. I just active something old and let them work in a new way.
Let me explain what preexisting concepts in my mind these visual parts have triggered and why they can represent characters of an active object.
First, in my mind I believe an individual in real world works sequentially. An individual cannot multi-task in the sense of concurrency on a multi-core computer where two actions may truly happen at the exact same moment. If you believe otherwise, you better put something else you believe that runs sequentially in the place of the image of the guy.
Second, an individual has a brain and hands. He has knowledge and is able to carry out services at his own pace. This kind of independency represents active object perfectly.
Third, user programs access an active object through a messenger object that offers a set of APIs so that it can fit for user programs in variant programming styles. From eyes of an active object, it only sees general requests without knowing the API method which was actually invoked. This is represented by the inbox in the visual element. The guy takes jobs from inbox without knowing where they come from.
I realize that the image of an inbox can bring confusion to some of you as it does not specify an order by which the guy takes jobs from the inbox. However it does not bother me as in my mind I always assume FIFO order for an inbox.
And last, an individual may ask help from or send notifications to other individuals. This is exactly how the number of active objects would grow in your application.
I hope by knowing why I am using this particular visual element to represent an active object, you may figure out your own visual element soon with ease.