29th November, 2009 - Posted by rafael.chaves - 1 Comment
I have been trying to figure out whether the TextUML notation for action semantics can be dealt with properly by tools such as Xtext and EMFText (class models and state machines should be fine). For example, given this structural model fragment:
class Advertisement
attribute summary : String;
attribute description : String;
attribute keywords : Keyword[*];
attribute category : Category;
operation addKeyword(keywordName : String);
static operation findByCategoryName(catName : String) : Advertisement[*];
end;
association AdvertisementKeyword
role Advertisement.keywords;
role advertisement : Advertisement;
end;
class Keyword specializes Object
attribute name : String;
end;
class Category specializes Object
attribute name : String;
attribute description : String;
end;
association AdvertisementCategory
role Advertisement.category;
role ad : Advertisement[*];
end;
Notice the Advertisement class declares two operations. Their behaviour in TextUML could be written as:
operation Advertisement.addKeyword;
begin
var newKeyword : Keyword;
newKeyword := new Keyword;
newKeyword.name := keywordName;
link AdvertisementKeyword(keywords := newKeyword, advertisement := self);
end;
operation Advertisement.findByCategoryName;
begin
return Advertisement extent.select(
(a : Advertisement) : Boolean {
return a->AdvertisementCategory->category.name = catName;
}
);
end;
Note that TextUML allows the behavior to be specified inline when declaring an operation in a class, or in separate, as above (that explains the lack of parameters, modifiers etc).
In the resulting UML model, the behaviour of Advertisement.addKeyword would roughly map to this (using a textual pseudo-notation for UML activities that is hopefully more readable than raw XMI):
activity(name: "addKeyword") {
structuredActivityNode {
variable(name: "newKeyword", type: #String)
writeVariable(variable: #newKeyword, value: createObject(class: #Keyword))
writeAttribute(
attribute: #Keyword.name,
target: readVariable(variable: #newKeyword),
value: readVariable(variable: #keywordName)
)
createLink(
association: #AdvertisementKeyword,
end1: #AdvertisementKeyword.keyword,
end1Value: readVariable(variable: #newKeyword),
end2: #AdvertisementKeyword.advertisement,
end2Value: readSelf()
)
}
}
and the behaviour Advertisement.findByCategoryName would map to this:
activity(name: "findByCategoryName") {
structuredActivityNode {
// implicit variable for return value
variable(name: "@result", type: #Advertisement, upperBound: *)
// implicit variable for parameter value
variable(name: "catName", type: #String)
writeVariable(
variable: #@result,
value: callOperation(
operation: #Advertisement.select,
target: readExtent(class: #Advertisement),
filter: metaValue(#@findByCategoryName_closure1)
)
)
}
}
// a closure is an activity that has a reference to a context activity
closure(name: "@findByCategoryName_closure1") {
// implicit variable for return value
variable(name: "@result", type: #Boolean)
// implicit variable for parameter value
variable(name: "a", type: #Advertisement)
writeVariable(
variable: #@result,
value: callOperation(
operation: #Object.equals,
// variables from the context activity are available here
target: readVariable(variable: #catName)
args: readAttribute(attribute: #Category.name, target: readLink(
association: #AdvertisementCategory,
fedEnd: #Advertisement.ad,
fedEndValue: readVariable(variable: #a),
readEnd: #Advertisement.category
))
)
)
}
Note that UML does not have closures, this is an extension to the UML metamodel which I wrote about here before.
Some background on the metaclasses involved: ReadVariableAction, CreateObjectAction, CreateLinkAction, ReadExtentAction etc are all action metaclasses. Actions are the building blocks for modeling activity behaviour in UML.
The million dollar question is: can Xtext and EMFText handle more complex textual notations like this? Is this out of the happy path? Has anyone done something similar? I am under the impression I could use Xtext or EMFText better if I used them based on a intermediate metamodel for behavior that would be closer to the concrete syntax (to get all the IDE bells and whistles for free) and then transformed that to UML in a separate step.
If you have the answers for any of these questions (or even if you have comments and questions of your own), please chime in.
Read More
20th November, 2009 - Posted by rafael.chaves - 3 Comments
Last Wednesday I attended the Eclipse Modeling Day in Toronto. Coming all the way from Victoria, I must have been the participant that came from farthest. Except, of course, those folks from SAP AG and Itemis that were presenting. But I was really glad to be there. I finally had the chance to chat and discuss about Eclipse and Modeling face to face with people like Simon Kaegi (server-side OSGi), Kenn Hussey (MDT UML2), Eike Stepper (CDO), Ed Merks and (fellow Brazilian) Marcelo Paternostro (EMF), Lynn Gayowski and Ian Skerret (Eclipse Foundation). It’s weird: I have been part of the Eclipse Modeling community since 2006 (and the larger Eclipse community since 2002), but had never actually met any of those folks before. Also amusing was that even though I worked for IBM Ottawa for quite a few years, my first time at the Toronto Lab was many years later as an ex-IBMer living on the West Coast.
The presentations I attended were in general very good. I had seen Ed Merks’ opening presentation on the web before, but this time I could ask questions. I got a better understanding of Xtext (great presentation!), CDO, and the Query, Validation and Transaction frameworks, some technologies I am considering adopting in the near future. I had a first time contact with the Papyrus 2.0 vision, which might provide an opportunity for increasing adoption of the TextUML notation by integrating the TextUML Toolkit into a larger modeling environment. And I liked the idea of a discussion panel at the end.
I had to catch a flight back home that same night, so I could not attend the Eclipse RT Day on the following day nor could I see any of the demos at the DemoCamp. Speaking of which, I did manage to stay long enough to have a beer on the Foundation (thanks!), and chat with Christopher Nagy from Dexterra/Antenna Software, who made a quick ad hoc demo to Ian and myself of their Eclipse/GEF-based tool for authoring multiplatform mobile applications. Very impressive!
As constructive criticism, I do agree with Bjorn that the format could use some tweaking. I sure had to miss some very promising presentations. Maybe with two presentation formats, a longer (for instance, 40-50 mins) and a shorter one (20-25 mins), we wouldn’t need two tracks. I am not sure presenters who came from Europe would have come had they had a shorter slot though. That being said, I was very satisfied with the event overall and am sincerely thankful to IBM Toronto for hosting the event, the Eclipse Foundation for organizing it, all the folks presenting and the companies sponsoring them. Thank you very much! As Lawrence wrote, hope we will see more events like this in the future!
Read More
6th November, 2009 - Posted by rafael.chaves - No Comments
Release 1.4 of the TextUML Toolkit is now available from the update sites, for both Eclipse 3.5+ and 3.4 (by the way, it is possible this will be the last major release targetting Eclipse 3.4, unless someone volunteers to generate and test builds for 3.4).
This is mostly a bug fix release. However, there were some minor notation changes to support stereotypes on dependencies, generalizations and interface realizations, hence the version change from 1.3.x to 1.4.x.
Thanks to Vladimir Sosnin, Attila Bak and fredlaviale for contributing with code and/or bug reports/feature requests. Keep them coming!
As usual, you can find a summary of the changes in the TextUML Toolkit Features page. If you are using the Toolkit, make sure you upgrade soon. If not, what are you waiting for? Install it already!
Read More