An Introduction To SonarJ for Eclipse
An Introduction To SonarJ for Eclipse
Join the DZone community and get the full member experience.Join For Free
SonarJ is a plug-in for Eclipse that helps you validate your code against a software architecture, using static analysis. Malai met the founder of the company behind the tool, to find out more about how it works.
Malai: So Alex, to start with can you please introduce yourself ?
Alexander von Zitzewitz: I studied computer science at the technical University in Munich (Germany). During my studies I was already very interested in Object Oriented languages and compiler construction. My master thesis was the implementation of a C++ compiler. (A project, that I regretted somehow, when I think how much time it took ;-( ) I finished in 1990. In 1993 I created my first company “ootec”, which was a software integrator doing projects (mainly C++ at that time) for large corporations like Siemens and Deutsche Telekom. This was the time when I had to learn the hard way about the importance of technical quality and a clean software structure for software projects. We acquired a nice fixed price project and started coding right away (we thought that we were smart enough to succeed without having to think about architecture and technical quality).
As you might have guessed this ended in a mess soon. Every code change broke something on the other edge of the project. Fixing bugs and adding features was quite difficult and took way longer than expected. Luckily to my rescue I found a very good book from John Lakos: “Large Scale C++ Design”. I read it over the weekend – more or less 500 pages of things we did not do right. After that experience we threw away what we had and started from scratch with a clean architecture and strict quality rules, also using some simple self made tools to check dependencies. At the end the project was a success, although we were very late and lost a lot of money on it. From then on I always had the vision to create a real usable tool for architecture management, but it needed another 10 years to come true. Long story – in the year 2000 I was able to sell ootec to the French Valtech group. They made an offer I could not refuse.
Malai: First of all, before we step into SONARJ, tell us more about Hello2Morrow. How did it happen and what is the vision and mission behind this company?
Alexander von Zitzewitz: In 2004 I became quite unhappy with the job I had at that time. I was working for a French company and had the task to create a market for a JDO solution. That job was quite hard, I had to compete against a well known good open source solution called “hibernate” with a product, that was sold at a high price. I said to myself, that if I had to work that hard I could just as well create a new company again. I had this idea when I was on a vacation in France. I was listening to a CD from Larry Carlton and the song that played was called “hello tomorrow”. I quite liked it and though, that this would also be a pretty good name for a company.
So I created the company in March of 2005 together with one of the best guys from my former ootec team (Dietmar Menges) and another guy (Peter Vieten), who had worked for one of ootec’s customers before. In summer of 2005 we had the first preliminary release of SonarJ, but it took until December 05 to win the first customers. Now we just try to create the best architecture management solutions on the market. BTW, in April we merged with our most important German competitor “Software-Tomography”, which enables us to also offer solutions for C# and C/C++.
Malai: What does SONARJ mean ?
Alexander von Zitzewitz: Peter had that idea, because it sounded somehow cool. Sonar waves are used to make invisible things visible (like submarines under water). SonarJ helps you to find the hostile submarines in your Java project. After we had the name we thought it could also mean “SOftware aNd ARchitecture” .
Malai: Does it only support Core Java or Application Development Projects using Java or any project that’s Java based including J2EE, J2ME ?
Alexander von Zitzewitz: We actually support everything that ends in Java byte code. Most of the analysis is done on the byte code level.
Malai: Can you give us a quick overview of SONARJ. What should people expect from a tool like SONAR J ?
Alexander von Zitzewitz: SonarJ comes as a stand alone version, an Eclipse plugin and as an ANT task or Maven Plugin. The stand alone version is used to model a logical architecture for a project and to map this architecture to the code. A logical architecture tries to define the big picture of an application (“blueprint”) and consists of elements like layers, vertical slices or subsystems.
The mapping is done by assigning Java elements like packages or types to the artifacts of the logical architecture. As soon as this had been done we can automatically compare the logical architecture with the code base and find and display all violations (dependencies, that are not foreseen in the logical architecture). This feature is of course especially useful in the Eclipse plugin, where violations are marked with error markers as soon as the developer saves a code change. This check is done within milliseconds, because SonarJ always keeps a very compact model of the code in memory, so that only changed files need to be reparsed. Besides checking the structure SonarJ can also check a couple of relevant software metrics and warn the developer, when a metric is out of range.
By using SonarJ you can expect to keep the structure of your code base clean and avoid the otherwise unavoidable structural erosion. If you use SonarJ on an existing project (90% of our customer are doing just that) you can stop and reverse the erosion process. Usually an investment in SonarJ pays for itself in less than a year not to mention that everybody will have way more fun working on the code, because it stays clean and elegant.
Moreover SonarJ makes it easy to bridge the gap between software architects and developers. Without such a tool architecture only exists in form of documents or UML diagrams. But you never know if your code really reflects the architecture. “The truth can only be found in the source code”. We are still quite surprised, that none of the big tool vendors offers a product in this segment.
Malai: I heard that Hello2Morrow is moving away from Germany to the US. Are you trying to shift your base?
Alexander von Zitzewitz: That is definitely not true. hello2morrow will stay a German company for the foreseeable future and we also develop SonarJ mostly in Germany. Our team currently consists of six developers. But we are expanding to the United States. I moved to Massachusetts this summer and created subsidiary here. BTW, the US subsidiary also covers India over local partners.
Malai: What are the licensing issues involved in SONARJ if someone is interested in using it … Do you have some community edition in place ?
Alexander von Zitzewitz: SonarJ is free for non-commercial use. All other use needs to be covered by a commercial license. We are thinking about a free community edition, that has a builtin project size limit (e,g. 200 classes), but that has not yet been decided.
Malai: Who are the target audience for SONARJ ?
Alexander von Zitzewitz: Everybody who writes non-trivial software in Java with 2 or more people working on the same code base. BTW, we will soon have a version for C#, called SonarShark (but it won’t bite you )
Malai: How does one get in touch with you if someone is interested to know more about SONARJ ?
Alexander von Zitzewitz: Best way is by email to firstname.lastname@example.org. To learn more about the product upfront I recommend to check out our website www.hello2morrow.com. It contains some webcast showing how to use the product step by step. You can also test the product for free within a 30 day evaluation period. Currently we just launched the beta program for SonarJ 4.0. The final release is scheduled for mid December 08. The two screenshots show the exploration view (green bows show dependencies counterclockwise) and the architecture grid view showing the layers and slices of an application. We have a patent pending on this view
Opinions expressed by DZone contributors are their own.