Skip to main content

TigerTeam TRIMM - Model Driven Generator just went Open Source

TigerTeam TRIMM – Model Driven Generator is just Open Sourced in July 2013. I myself never heard of this product before and found this product by coincidence as I tried to find a JPA 2 standalone cartridge / generator available in Internet. I know that AndroMDA has some cartridges to persist Java objects but as far as I know AndroMDA only support persistence in the context of EJB 3 not as standalone JPA.

After I found this product I began to analyze the code at Bitbucket.org and found out that the idea with the Events and Listeners as Extensions is a very good idea. TRIMM also uses Maven completely and does not have any dependencies to Eclipse plugins, so you are Eclipse independent. Special to this framework is that it uses its own metamodel and does not use UML2 metamodel for the generators. TRIMM should work for MagicDraw and Enterprise Architect and it can read the files directly from those UML tools. It also uses its own Java code generator which is basically based on String outputs. A very good thing is that TRIMM offers some ready to use cartridges like Java, JPA 2 and Webservice.

It seems that TRIMM does not suffer the problems I mentioned in my older Java article at Java Lobby post and uses almost the same approach of KissMDA. Following are the differences I can see in a glance:

(1) TRIMM is using its own Java generator which is basically based on String outputs and this is not the best way to generate Java codes. Using Eclipse JDT is a lot more easier and you always get syntactically correct Java codes which can be easily unit tested like this KissMDA example.

(2) Interesting to compare the transformers for Java code generation. In TRIMM you have the class JavaGenerator.java. In KissMDA you use the class SimpleJavaTransformer.java. They both are the main entering point for the generation of Java codes. Both classes look quite similar from the way of doing the works they need to do. Using DI framework like Guice in KissMDA makes the code more readable and easier to understand.

(3) Unit tests are crucial in KissMDA. The simple Java cartridge has in the mean time about 35 test cases. This is possible because we use Mockito extensively. TRIMM Java cartridge has also some unit tests which are not many in comparison with the available implementation classes.

I really like the idea of using Events and Listeners to plug the extensions. In this context I will try to write the next KissMDA cartridge which will be a JPA 2 cartridge using Events, Event Bus and Listeners. As a foundation I will use this easy and simple Event Binder framework: GWT Event Binder. In the mean time I found some Open Source Event Bus implementations like Guava and MBassador. This is a good blog which compares those Event Bus frameworks: Java Event Bus Library Comparison. My choice is MBassador because it supports Weak References in Event Bus.

Congratulation to the team of TRIMM and I  think, it is a very good move to Open Source TRIMM. I wish all the best for the future of TRIMM!

Comments

Anonymous said…
Hi. Thanks for your coverage and feedback on TRIMM :)

The JavaGenerator uses a mixed model for java Code generation. Where possible and feasible we use a CodeModel (which is resembles the .NET CodeDOM). This means all main concepts such as Class, Interface, Enumeration, Constructor, Methods incl. arguments/return-value, Parameters, Fields all have a Java object model representation. For the Code inside methods/constructors we switch to CodeSnippets which uses String concatenation. Sometimes we skimp on using the CodeDom for certain extensions and use CodeSnippets exclusively. It's a tradeoff that we try to make very consciously.

The use of the CodeModel allows us to reuse 80% of the Code generation for Java when e.g. generating Groovy Code. The largest difference is the CodeSnippets and especially the CodeWriter and CodeVisitor that's used: GroovyCodeWriter which uses the GroovyCodeWritingCodeVisitor instead of the JavaCodeWritingVisitor.

This allows you to write Code in the following fashion:
Constructor constructor = new Constructor(CodeElement.AccessModifier.Public);
for (Property immuteableProperty : immuteableProperties) {
constructor.addParameters(new Parameter(immuteableProperty.getName(), immuteableProperty.getField().getType()));
if (!superClazzImmuteableProperties.contains(immuteableProperty)) {
constructor.addCode(new CodeSnippet("this.", immuteableProperty.getField().getName(), " = ", immuteableProperty.getName(), ";"));
}
}
event.getClazz().add(constructor);

Regarding the Unit testing then you're right, the amount of Unit tests are smaller compared to the amount of Code. We basically only Unit test the Core parts (parser, generator).
For most other parts, we rely heavily on vertical slice testing/integration testing. We have created several Example/test projects, which tests large parts of the Code generator and many of the extensions. We then rely on automatically generated unit/integration-tests (e.g. JpaUnittestCreator) to create integration tests for the Code we generate based on a model.
We have used TRIMM in production since 2008 and many large projects and this approach has so far proved sufficient.
Again, it has been a tradeoff of delivering quality on time and still trying to maintain the quality over time.

If you have more feedback, I would love to hear it :)

/Jeppe
lofidewanto said…
Thanks for your fast feedback and explanation!

As I said in my blog, TRIMM is the *first* MDSD framework which matches my vision of how MDSD framework should look like. Very pragmatic, lightweight and completely independent of IDE like Eclipse. So, IMHO, TRIMM is very nice. Don't worry I'll take further look on TRIMM and will give you a lot more feedbacks ;)

It's a pitty that I never heard TRIMM before it became Open Source. In January this year I wrote an article about "MDSD state of the art" at German's online developer magazine called heise Developer: http://heise.de/-1776860 and at that moment I did not know the existence of TRIMM.

Let me know, if there are things we can work together between KissMDA and TRIMM.

Thanks,
Lofi.
Anonymous said…
Just for your information, we have recently released a new snapshot of TRIMM with support for Spring Data Mongo.

You can read more here: http://trimm.tigerteam.dk/trimmmongo-1-0-1-snapshot-support-spring-data-mongo/

/Henrik

Popular posts from this blog

Why "Polyglot Programming" or "Do It Yourself Programming Languages" or "Language Oriented Programming" sucks?

Last year we saw the launch of a new Web programming language Dart - Structured Web Programming from Google. A very interesting approach to support web application development. Not so long after Go, Groovy, Ruby, Scala, << name your DSL here >> ; we see Dart. Is it a good thing to have at least one programming language to solve one problem? The answer is, like we already know, it depends. Some important backgrounds you should know about the multi programming language paradigm are following: 1. You can read Martin Fowler article about language oriented programming with language workbenches which enables you to write small programming languages easily. In this article I see everyone writing their small languages, everywhere. In this concept we see DSL (Domain Specific Language) as the future of our programming activities. Source: http://martinfowler.com/articles/languageWorkbench.html 2. Neal Ford talked about Polyglot Programming, combining multiple programming language...

Software Development Macro and Micro Process

If you think that in year 2012 all companies which produce software and IT divisions in our world have already their optimized software development process, you are wrong. It seems that we - software architects, software developers or whatever your title is - still need to optimize the software development process in many software companies and IT divisions. So what do you do if you enter a software company or IT division and you see following things: 1. There is a perfect project management process to handle all those development of software but it is a pure project management without a context to software development. So basically you only take care of cost, time, budget and quality factors. In the software development you still use the old fashioned waterfall process. 2. From the tooling point of view: you have a project management planning and controlling tool but you are still in the beginning of Wiki (almost no collaboration tool) and you don't use issues tracking sy...

Creating Spring Bean dynamically in the Runtime

In my training someone asked me whether it is possible to create an object (a Spring Bean) dynamically so you can choose which implementation you want to have  in the runtime . So at the compile time you don't know what object actually should be created yet. The application should decide what object to be created based on a property file . 1. We create an annotation so we can mark the method which should be able to create the object dynamically: ... package your.package; ... @Retention(RetentionPolicy.RUNTIME) public @interface InjectDynamicObject { } ... 2. Use the new created annotation in your method which should be able to create the object dynamically: ... @Named("customerBo") public class CustomerBoImpl implements CustomerBo { ...     @Override   @InjectDynamicObject   public Customer getDynamicCustomer() {         return this.dynamicCustomer; } ... 3. Write an aspect with Pointcut a...