Site icon IT World Canada

Code maintenance and reliability

Two issues ago I said development teams should use tools that can measure quality if they want to ensure the success of their Java/J2EE projects. This time, I’ll discuss which open-source tools can help measure the maintainability, reliability and performance of Java or J2EE-based systems.

Code generation

Code generation is one of the best ways to ensure consistency and quality for repeatable code that differs based on type. XDoclet, currently the industry standard for generating Java source code, is an open source, free library that parses the codebase, looking for custom Javadoc tags (metadata) it can use to generate other Java source files. The library contains Javadoc tags that may be used to generate most of the repeatable code found in most Java/J2EE-based systems. It also supports many other technologies such as Hibernate, JDO (Java Data Objects), and Castor.

Code metrics

Code bases are so large that it’s just not possible to visually monitor them. Developers can instead use metrics to identify problems. The Metrics plug-in for Eclipse is an open source, free tool that can generate metrics on a per-class, per-package, or per-project level. The results may be exported to an XML file for historical purposes. The plug-in provides more than 23 types of metrics.

Code reviews

Code reviews help ensure code quality while training and mentoring developers on coding style and best practices. Jupiter is an open source, free tool that enables team-based code reviews. The tool uses XML files to track individual team member reviews with a review ID and a reviewer ID. These files are checked into source control and made available to other developers, enabling simultaneous multiple reviews.

Standards adherence

Development standards exist to ensure past mistakes are not repeated and that code is consistent and more readable for the developer who will maintain it. Eclipse comes with a built-in code formatter that adheres to Java coding conventions — but it’s not enough to ensure the production of quality code. Checkstyle builds upon Eclipse’s code-formatting capabilities by identifying non-compliant code blocks, coding problems, duplicate code and some metrics violations. The tool is extremely customizable, enabling the user to tailor the types of checks and their level of severity according to the organization’s development standards.

Functional testing

Eclipse ships with both Ant and JUnit. Ant is the de facto industry standard for building Java-based applications. JUnit is a Java-based framework for creating unit tests. Developers can set up JUnit tests to run in Eclipse, which provides a special view for the JUnit results, or use the Ant JUnit or JUnitReport task. The JUnitReport Ant task creates an HTML viewable report that may be used to represent the entire system’s tests, or specific tests.

Code coverage

When developers write unit tests, they should understand how much code base coverage the tests provide. Grobo-CodeCoverage, an open source coverage tool, integrates with Ant by providing an Ant task that can generate coverage reports. The cornerstone of the tool is its Source Summary Coverage Report. This report mimics the Javadoc structure and provides a quality professional report that may be stored for historical purposes. As the project progresses, the report can be referenced to understand whether code coverage increases or decreases over time. By using the tool, developers can ensure their most critical code pieces are fully exercised and pinpoint areas that lack coverage.

Profiler

As projects near the end of the construction phase, developers start thinking more about performance. Profiler for Eclipse is an open source, free profiler that shows the threads, heap size, heap dump, method calls, method times, calls per package, and thread call-trees, which allows developers to see where time was spent through the flow of a call. The tool helps developers understand where the application’s bottlenecks are occurring, allowing them to correct problems.

Two issues from now I will describe how to implement quality control processes for J2EE- or Java-based projects.

Jarrett is an enterprise architect with The Cobalt Group, a Seattle software development firm.

Quick Link: 057946

Exit mobile version