16th September, 2008 - Posted by rafael.chaves - No Comments
Shorthand notation for both composite and aggregate associations has just been checked in (r99-r100). It follows the same spirit as the existing shorthand for plain associations (a.k.a. references).
composition <end-name> : <referenced-type-name>;
or
aggregation <end-name> : <referenced-type-name>;
That will result in a new unnamed association with two member ends, one named, owned by the declaring classifier, with composite or shared aggregation type, and another unnamed, owned by the association itself.
Change set explained
When adding a new feature to the notation, the typical change set contains:
- updates to the affected grammar production rules
- implementation of the corresponding model generation handling code
- a few test cases.
In the case of the features presented in this post, the grammar change was quite simple (nicer view):
--- trunk/plugins/com.abstratt.mdd.frontend.textuml.core/textuml.scc 2008/09/16 05:47:13 99
+++ trunk/plugins/com.abstratt.mdd.frontend.textuml.core/textuml.scc 2008/09/16 05:47:20 100
@@ -341,7 +341,9 @@
attribute_decl = attribute identifier colon type_identifier optional_subsetting semicolon ;
- reference_decl = reference identifier colon type_identifier optional_subsetting semicolon ;
+ reference_decl = reference_type identifier colon type_identifier optional_subsetting semicolon ;
+
+ reference_type = {association} reference | {composition} composition | {aggregation} aggregation ;
optional_subsetting = subsets qualified_identifier | {empty} ;
In other words, where one could declare a reference, one can now declare also a composition or an aggregation (gotta love the readability of SableCC grammars…).
The corresponding model generator (a.k.a. compiler) changes were quite trivial as well, even more so if you consider I inadvertently checked in a fix to an unrelated bug around comments (just ignore the changes in lines not in the 300′s).
In terms of lines of code, the bulk of the changes were in the test class for associations, where I added three test cases. I had postponed writing tests for the reference shorthand notation, so I took this opportunity to write a test for it too.
As most test cases in the TextUML Toolkit test suite, the new test cases in AssociationTests have the following layout:
- one or more compilation units with TextUML source code are declared
- source code is compiled and the resulting errors verified (most test cases won’t expect errors)
- the resulting model is checked – were the expected elements created? Do they have the expected features?
Talking about tests
The TextUML Toolkit has a modestly sized test suite (~130 test cases) at this time. It could use dozens, probably hundreds more, but most features are covered to so some extent.
However, as important as coverage, is how much one can learn about the piece of software being tested by reading its test suite. And here is where I believe the TextUML Toolkit’s test suite shines. For example, by reading the test classes, one could (maybe more effectively than by reading the notation guide), learn how the following UML features are exposed by the TextUML notation:
Trivia: can you find out from the test suite the difference between a private and a public package import? Give it a try and let me know if I am lying… by the way, the notation guide does not cover that yet, although the UML specification, of course, does.
Read More
10th September, 2008 - Posted by rafael.chaves - 5 Comments
I often see the TextUML Toolkit being compared to tools that produce UML diagrams from textual descriptions. Examples of tools like that are ModSL, MetaUML and UMLGraph. But that doesn’t really make sense, and here is why: these tools produce diagrams from text. The TextUML Toolkit produces models from text. But what is the difference between models and diagrams?
According to Wikipedia:
- A diagram is a 2D geometric symbolic representation of information according to some visualization technique.
- A model is a pattern, plan, representation (especially in miniature), or description designed to show the main object or workings of an object, system, or concept.
Note that even though both terms are defined around the word “representation”, the term “diagram” implies graphical visualization, whereas the term “model” admits any kind of media, basically because models have no concrete form per se.
Now, please, if you are not convinced yet, read aloud 5 times: MODELS ARE NOT DIAGRAMS!
If that didn’t work, well, maybe the facts below will help:
- models, not diagrams, are the subject matter of model-driven development.
- models, not diagrams, can be validated.
- models, not diagrams, can serve as input to code generation.
- models, not diagrams, can be automatically generated from reverse engineering source code.
- models, not diagrams, can be executed.
Even though diagrams are commonly used for representing models, they are not the only way, and non rare not the most appropriate one (yes, I am talking again about the virtues of textual notations, but I won’t repeat myself).
P.S. Maybe it helps adding to the confusion the fact that the TextUML Toolkit has an optional feature that will generate class diagrams automatically from the UML models created with it. However, that is just an optional, loosely integrated feature, and it is definitely not the Toolkit’s thing. Weirdly enough, from my observation, that feature is the main reason most people become interested in the TextUML Toolkit. Well, go figure.
Read More
2nd September, 2008 - Posted by rafael.chaves - 5 Comments
TextUML Toolkit 1.1 is out! This is the first release after the TextUML Toolkit became an open source project. Besides the adoption of the Eclipse Public License, these are the new features that were added in 1.1:
- more UML features exposed by the textual notation: abstract operations and parameter direction modifiers
- more diagram layout controls (compartments, elements across packages)
- support for exporting the class diagram to a PNG or JPG image file (actually, an EclipseGraphviz feature, also available for other graphical content providers)
Also, the TextUML Toolkit is not available any longer as a standalone download. You need to install Eclipse 3.4 first (3.3 support was dropped) and then install the TextUML Toolkit using the new smart Software Updates mechanism in Ganymede. See new install instructions here.
As usual, feedback is most welcome – blog, issue tracker or forum, whatever option works best.
Read More