Saturday, March 27, 2010

Back from EclipseCon 2010

I came back to home today, after one week at Santa-Clara, near San-Francisco, attending my second EclipseCon.

Last year, I only presented a poster. But this year I gave a talk about MoDisco and I participated to the Modeling Project runway organized by Kenn Hussey. Gabriel Barbier, my colleague from Mia-Software, had also a talk with Henrik Lindberg about B3 and the possibility to use MoDisco to extract build information from source code .



Once again, I really enjoyed the conference and its organization: lots of interesting talks, very good keynotes (Steve Harris show was THE event of the week), but most of all it is the best way to share ideas, to meet people and to show what we working on.

This year, we spent a lot of time explaining a project we propose to create. The EMF Facet project will provide mechanisms to dynamically extend ECore models: adding properties, references, operations without changing the initial ECore model. These mechanisms have already been developped as part of the MoDisco project. We propose to externalize them to make them more reusable by other projects. We received very good feedback on this project from all the Modeling Project members to whom we presented our ideas and the existing components. We will first submit the proposal to the Modeling PMC next week.

Wednesday, March 24, 2010

Reverse-engineering of JUnit tests


Tuesday I presented MoDisco during two EclipseCon sessions at Santa-Clara:

We decided this year to illustrate MoDisco with a example based on JUnit :
  • reverse-engineering of source code containing JUnit tests (we took draw2d as a sample)
  • creation of a fine-grained EMF model describing the source code
  • definition of an extension (Facet) to find the JUnit Test suites, Test cases and Tests contained within the code



  • colorization (UICustom) of the packages, classes and methods to be tested, depending on how many tests are defined for them



  • transformation of the EMF model and regeneration of the source code to migrate from JUnit3 to JUnit4
The slides are available here.

I will blog soon to give more details about this JUnit use-case.


Tuesday, February 2, 2010

MoDisco 0.8M5 available for download


Version 0.8M5 of MoDisco, has been released yesterday : http://www.eclipse.org/gmt/modisco/downloads/

It already embeds the components which will be available in the final 0.8 version running with Helios.

Today I would like to focus on two new components (Query Manager and Facet Manager) and how they are used by the new version of the Model Browser to allow defining custom (and dynamic) viewpoints on your EMF models.

These mechanisms have been developped to support understanding of complex models automatically created from legacy source code. But you can also use it on "classic" EMF models created manually with graphical tool such as Papyrus.

Query Manager (new)

This is a new component providing a facade to evaluate queries against an EMF model independently from the query mechanism. Implementations are provided to call queries written in Java, EMFQuery, OCL and XPath.

A QuerySet containing OCL and Java queries


Facet Manager (new)

This new component provides a mechanism to dynamically extend EMF model elements by adding "virtual" attributes and relations computed by queries.


ModelBrowser

The look & feel has been reviewed to be more compliant with Eclipse UI checklist.

With the new version it is possible to dynamically customize how the EMF model elements are displayed. Any customizable feature (label, color, icon, police, ...) can be set statically, or dynamically using a Query executed on each element to display.

Wizard to customize the Browser for a given metamodel

You can also execute a Query against a model element directly from the browser

Selection of a model element from the Browser

Selection of Query to execute on the selected element

Result of the Query displayed in a table

If you want the Query to be always executed on each element of the same type, you can define a Facet to see the Query as a virtual type, attribute or relation in the browser.
The Query "subClassifiers" visible as a "virtual" relation on Class


Friday, January 29, 2010

How to create an EMF model from a Java application ?


Is it possible to reuse EMF-based tools with Java source code ? Yes if you have your Java source code translated into an EMF model.

This is the aim of the Java component provided by MoDisco. This component is composed of a ECore definition of a java application and a discoverer which creates EMF models from an EClipse project containing Java source code.

The ECore definition declares all the concepts of the Java language : Package, ClassDeclaration, MethodDeclaration, Parameters, VariableDeclaration, IfStatement, Assignment, CastExpression, LineComment, ...

To create an EMF model using this metamodel, select your project and right-click on the menu "MoDisco>Discover Java model from Java project...". A wizard appears to select the analysis options :
  • You can extend the analysis to dependencies (the JAR used by the project).
  • You can use an incremental mode if you need to optimize the memory usage
  • You can limit the analysis to declaration members if you don't need a model of the instructions contained within the methods
  • You can use a filter to exclude Java classes during the analysis

The result is an EMF model which can be opened with the EMF reflexive editor or with the MoDisco generic browser. This browser allows accessing directly to instances of a specific class (for example all the MethodDeclarations) and navigating through all the references (composed or not).

This model can be used with other EMF-based tools to check architectural or coding norms, to generate other models (UML or Domain-Specific) or to regenerate an other application (if you modify the Java model, MoDisco provides templates to regenerate Java source code).

Monday, November 30, 2009

EMF and SMM to export code metrics to Sonar and Squale

How to facilitate the integration between code quality measurement tools and code quality reporting tools ?


This is the problem we are faced with at Mia-Software: to address modernization projects, we have developped a lot of parsers creating models of code from which we can compute quality metrics (from COBOL, Natural or VB6 to Smalltalk, C# or Java). But as our customers are interested in getting these metrics in the quality report tool of their choice, we don't want to multiply the development of adhoc bridges (one for each couple "metrics calculator" <-> "report tool")

To reduce the cost of bridging the tools, we chose SMM (Structured Metrics Metamodel) as a pivot. SMM is the OMG/ADM standard for defining metrics related to software and for representing their measurement on existing systems. Its reference EMF implementation can be found in MoDisco, the Eclipse Modeling project focused on discovering models from software assets.

The main classes defined by SMM are quite simple :
- Measure : the definition of an indicator (nb lines of code, cyclomatic complexity, …)
- Scope : the kind of elements on which the indicator can be measured
- Measurand : an element on which an indicator has been measured
- Measurement : the measured value of an indicator
- Observation : who ? how ? when ?
Then, for each measurement tool that we need to integrate with a report tool, we just have to create a SMM model describing the kind of metrics to exchange (instances of Measure and Scope) and a connector to translate the specific export format of the measurement tool to a SMM model containing the measured values (instances of Measurement, Measurand and Scope).

In parallel, we create one generator for each report tool to integrate with. This generator takes the SMM model defining the measures and generates :

• the files declaring the metrics within the report tool
• the files configuring the report tool to integrate the new kind of metrics
• the source code of the component which will import SMM models containing the measurements
At this time we have experimented this approach to import COBOL and VB6 metrics (calculated by Mia-Insight) into the quality report tools Sonar and Squale.

Screenshots : COBOL -> Sonar







Screenshots : COBOL -> Squale







Our conclusion is that SMM fits the need of integration between these kind of tools.

The next step will be the integration of XRadar (suggestions of other report tools are welcome ;-) ).

We also have to solve the problem of metrics aggregation. There are three possibilities :
- aggregation at measurement time
- aggregation in SMM model
- aggregation in report tool
We have already identified pros and cons for each alternative. Depending on the kind of aggregation to perform, experimentation will probabely give an answer !

Saturday, October 31, 2009

Eclipse Summit Europe 2009

This year was my first attending ESE, and it was worth it !

The talks on modeling were very interesting (Xtext, EMFQuery, Papyrus, ...) and it was nice to meet the guys directly involved in the projects we are interested in.

The Cloudsmith team, for example, to discuss how we could use MoDisco on the B3 project to analyse plugins and create models of builds. Or André Dietisheim about our tests with CDO to manage models of large Java applications created with MoDisco. Nice also to talk with Kenn, Ed, Ralph and many others.

I had the chance to talk during both the Modeling Symposium (Tuesday) and a session dedicated to MoDisco (Thursday).

With my colleague Gabriel Barbier of Mia-Software, who presented the demo Thursday, we shown how to create fine-grained models from Java source code (based on a Java.ecore metamodel), and how to navigate through this model with the model browser we have developped. We put the focus on the customization and the extensibility of this browser by using queries.

You can dynamically change the icon, color, font ... of the instances of your models (by defining a UICustomization, stored in a EMF model), or add "virtual" types (not originally defined in your Ecore metamodel) with "virtual" properties and references (by defining a RoleSet, also stored in a EMF model). The query mechanism that we provide is generic : it allows integrating queries written in Java, EMFQuery, OCL, XPath or ATL.


We presented the 0.8 version which is still under development (planned for the end of 2009). But thanks to Nicolas Bros who have put the releng in place, it is possible to download an integration build.

The demos are online :
- Demo during the Modeling Symposium
- Demo during the MoDisco short talk