I'm trying to model my Application with UML Activity Diagrams. I'm using JavaScript and Node.js and lots of asynchronous callbacks. Here is what I came up with:
What do you think? Do you understand whats going on? I'm using a "generic connector" to associate the callback with the action ("run MyClass.myMethod) and a fork-node to show the "parallel" execution. I did not find a written word about callbacks in Activity Diagrams anywhere on the web or my books.
EDIT This would be the JavaScript code for the diagram:
var MyClass = function () {
//constructor
};
MyClass.prototype = {
myMethod : function(cb) {
//this is an async method
var result = 5 + 5;
setTimeout(function () {
cb(null, result);
},100); //execute Callback after 100ms
}
};
//instanciate a MyClass Object
var myClassInstance = new MyClass();
//create a callback function that prints the result
var callbackFunction = function (err,result) {
console.log(result);
};
myClassInstance.myMethod(callbackFunction);
console.log('I am first');