Create high quality code with IDE's

Integrated development environments (IDEs) give developers specialized tools to create software. Rational Software Architect and Rational Application Developer are IDEs that provide automated tools to quickly create high quality code. An IDE makes it easier to detect, prevent, and resolve defects as the software is being developed. The savings gained by more efficient software maintenance can be applied to the effort to create more innovative products to increase revenue.

Charles E. Gordon (cegordon@us.ibm.com), Technical Sales Specialist, IBM

Charles joined Rational in 2000 and has supported the IBM Rational architecture, design, and construction products (including Rational Software Architect and Rational Application Developer) for several years. Prior to joining Rational, Charles was a software developer for more than twenty years.



12 November 2013

Also available in Chinese Russian

Introduction

Integrated development environments such as IBM® Rational® Software Architect and IBM® Rational® Application Developer for WebSphere Software improve code quality by making it easier to catch defects earlier in the development cycle. Because it takes longer to analyze and design changes to software than it takes to implement the changes, an IDE must provide automated tools to help visualize the impact the changes will have. Such an IDE minimizes the likelihood of negative impacts from changes and simplifies the impact analysis process.

Continuous integration is a key part of today's software development environments. An IDE that supports numerous, frequent software updates and releases can ease the interaction of development and operations (DevOps) organizations. An IDE helps to reduce time-to-market

This article gives a quick overview of the features in Rational Software Architect and Rational Application Developer that help you to avoid defects and find and fix them early in the development process, resulting in higer quality, easier to maintain, and timely code.

Note:
Rational Application Developer for WebSphere Software is included in Rational Software Architect for WebSphere Software but can also be bought as a standalone product. Any Rational Application Developer capabilities mentioned in this article also apply to Rational Software Architect for WebSphere Software.


Transformations to automate new development artifacts

Transformations take a set of elements and change them into a new set of elements. The elements are changed based on the rules used by each specific transformation. The transformation provides an automated way to create development artifacts that conform exactly to the intended architecture or design. This helps you to build what your customer requested.

The types of Rational Software Architect transformations are:

  • Model-to-model
  • Model-to-text (code)
  • Text-to-model
  • Text-to-text

This article focuses on the model-to-text and the text-to-model transformations because they provide the ability to generate code (and code-related artifacts) from architecture and design models and the ability to do the reverse transformation. Examples of Rational Software Architect model-to-text transformations include UML to Java, UML to C#, UML to WSDL, UML to SOA, and UML to SCA. For many of these transformations, it is also possible to reverse the transformation to create models from the development artifacts, for example, Java to UML. (Reverse transformation is not the same as visualization, which is discussed later in this article, because the artifacts are not necessarily inextricably tied to the model). Reversing the transformation can help you better understand software structure and implementation. It can help to eliminate errors when you create or modify code. Reverse transformations also provide a way for you to update your original models. You can also extend the transformations provided by Rational Software Architect or create new transformations.

To use a transformation, create a transformation configuration that specifies various parameters for the transformation. Transformation type, source, target, mapping, etc., are a few of the parameters. Then run the transformation, which puts its output in the specified target, a project such as a Java project. An example of a transformation configuration is shown in Figure 1.

Figure 1. Transformation configuration
Specify parameters for a transformation

Click to see larger image

Figure 1. Transformation configuration

Specify parameters for a transformation

Automation to develop code through wizards

Wizards are automated tools that perform complex tasks. They gather relevant information or parameters for those tasks, then run the tasks. Rational Software Architect includes many wizards related to a wide range of activities from project creation to code generation. The wizards improve code quality by creating the desired output in a proven, repeatable, timely manner. Some of the outputs can be very large, for example, hundreds of lines of code from an EJB wizard. The automation provided by the wizard creates all of that output without error in a matter of seconds or minutes.

Rational Software Architect has several wizards that support the following technologies:

  • Java technology
  • Web services
  • Enterprise Java Beans (EJBs)
  • Web projects
  • Patterns
  • Database connections
  • Generating tables and entities
  • Java 2 Connector (J2C)
  • Physical data models

An example of the Web Services creation wizard is shown in Figure 2.

Figure 2. Web Services creation wizard
Options, parameters to create a web service

Validators to check files and code against rules

Rational Application Developer provides a number of validators that each validate a different type of development technology. The validators check files or source code against rules for that type of technology, such as JAX-RS, and report any errors found. Validators improve code quality. They can automatically scan large amounts of code quickly and can detect subtle as well as more obvious defects. These defects are very time consuming and difficult to discover. By default, validation runs automatically when a build is run. It is also possible to manually run a validation at any time. Validation can be tuned by enabling and disabling various validators. Filters can also be set up so that validation is run only on specific artifacts. Validators can be managed using the Validator preferences, an example of which is shown in Figure 3.

Figure 3. Some of the validators in Rational Application Developer, along with preferences
Validators and settings

Click to see larger image

Figure 3. Some of the validators in Rational Application Developer, along with preferences

Validators and settings

Visualization of code to make structure more apparent

Rational Application Developer helps you to visualize your code throughout the creation of dynamic topic diagrams and by supporting manually created class diagrams. The diagrams enable you to quickly see and understand the structure of your source code. Code quality is improved when developers better understand the structure of the code as they are implementing new code or modifying existing code. Visualization can be used to document code so that others can better understand it. With the diagrams created by visualization you can visually edit the code. These visualization capabilities increase your productivity, automate documentation, facilitate collaboration with your team, and automate and simplify repetitive tasks such as creating classes or methods.

Visualization creates code-centric UML diagrams that are exact representations of your source code. Any changes you make to the diagrams are instantly reflected in the source code and the reverse is also true. In other words, the diagrams are the code. This is where visualization differs from the transformations, in that code created by transformations can be maintained separately from the source models. An example of a visualized Java class is shown in Figure 4. Note that the attributes and methods for the class match exactly in the diagram and in the Enterprise Explorer.

Figure 4. Model created by visualization of Java code
UML class diagram created by Visualization

Topic diagrams are non-editable, query-based diagrams that you can use to quickly show relationships between elements. For example, you could select a Java class and create a topic diagram that shows all of the other Java classes that are related to the selected class. An example of a topic diagram is shown in Figure 5.

Figure 5. Topic diagram
Classes and relationships in UML diagram

Environment to test WebSphere applications

The WebSphere test environment is a runtime environment that is integrated into the workbench for testing applications that are targeted for WebSphere Application Server.

The test environment for WebSphere Application Server requires a full installation of the WebSphere Application Server (provided with Rational Application Developer) and is enabled through a run server with resources within the workspace publishing setting. If you already have a WebSphere Application Server installed on your machine, you do not need to install the test environment. Your existing server can be safely used for testing and used as an external server. You can set the publishing setting to publish to a test environment and or to an external server. See the topic on setting publishing preferences in the WebSphere Application Server information center for more details.

The WebSphere test environment offers the following benefits:

  • Standalone, all-in-one testing
  • Supports hot method replace (enables you to make changes to your code while debugging and have those changes take effect without restarting the server)
  • Provides the ability to debug live, server-side code at full speed
  • Enables you to run WebSphere administrative scripts
  • Enables you to debug Jython scripts
  • Enables you to generate WebSphere administrative commands to assist in developing Jython scripts
  • Enables you to configure multiple web applications
  • Supports multiple servers that can be configured and run at the same time
  • Provides access to the profiling feature
  • Provides the ability to use version control for server configurations
  • Provides a Universal Test Client where you can test your enterprise beans, Java Persistence Architecture (JPA) and Java™ classes
  • Provides access to the WebSphere Application Server Administration Console
  • Provides the ability to automatically create tables and data sources for testing container-managed persistence (CMP) beans and JPA

Rational Application Developer V9 supports WebSphere Application Server versions 7.x, 8.0.x, and 8.5.x. In addition, the Liberty profile for WebSphere Application Server 8.5 is also supported. The Liberty profile is a lightweight WebSphere Application Server profile that features quick startup and restart times and is intended primarily for web applications that do not require the full Java EE environment.

You can install multiple WebSphere Application Server servers in your Rational Application Developer environment using different WebSphere Application Server versions.


Tools to profile Java applications

Rational Application Developer includes several powerful tools to profile Java applications. To analyze the behavior of a running application, profile it so that you can understand various aspects of the application's behavior and improve the application by refining it in specific areas. Rational Application Developer enables you to profile the following areas:

Memory
Indicates which objects are in memory and helps to detect memory leaks
 
CPU
Shows how much CPU processing is happening in each line of your code and enables you to identify bottlenecks
 
Threads
Shows thread activity, identifies thread deadlocks, and enables you to analyze thread behavior
 
Pattern extraction
Enables you to monitor multiple processes on multiple machines. Makes it easier to analyze process interactions.
 
Distributed processing
Enables you to monitor and profile multiple processes on multiple remote machines. Enables you to analyze applications running on their target environments.
 

With Rational Application Developer, you can profile on both local and remote machines, including local and remote WebSphere Application Servers. To profile on remote machines, install the Agent Controller on the remote machine.

A CPU profile can generate dynamic interaction diagrams for classes and threads. An example of a class interaction diagram is shown in Figure 6.

Figure 6. Class interaction diagram
UML interaction between classes

Probes are related to profiles. Probes are Java code fragments that are used to collect runtime data about an application. The Eclipse platform that Rational Application Developer uses provides a Probekit that is used to create and use probes. The Probe kit is typically used for probes that collect data of interest to developers, for example, print entry and exit information for methods.


Software Analyzer to detect issues early

The Rational Software Architect Software Analyzer feature improves code quality by helping to detect issues as early as possible in the software development lifecycle. Various types of static analysis can be configured. The Software Analyzer scans development artifacts, applies the selected analysis configuration, and reports the results of its analysis in the following categories:

Code review (Java code and C++ code)
More than 400 review rules are available and rules can be extended. You can choose which rules to apply to the analysis. The reports can be viewed by rule or by resource.
 
Java architectural discovery (Rational Software Architect only)
Identifies and models patterns and anti-patterns found in the source code.
 
Java software metrics (Rational Software Architect only)
Generates several types of metrics, including Complexity, Halstead, Coupling, and Inheritance.
 
UML model metrics (Rational Software Architect only):
Identifies various characteristics of a UML model, including Coupling, Diagrams statistics, Inheritance, and size.
 
UML model review (Rational Software Architect only)
Compares the UML model to review criteria and flags any non-compliant model elements.
 

The review functions enable you to set the level of severity for items that are found to be out of compliance with the review rules. This setting helps you quickly identify outliers and find potential trouble spots to be rectified.

A sample Java code review report is shown in Figure 7.

Figure 7. Software metrics compiled by the Software Analyzer
Software metrics and values for code

Rational Test Workbench to test applications

Testing is a vital activity in improving code quality. Testing validates that applications properly implement requirements and identifies defects when applications have errors that prevent expected application behavior. Various types of testing, including functional testing, performance testing, and test virtualization are supported and run by IBM® Rational® Test Workbench.

IBM® Rational® Quality Manager enables you to manage test plans, test cases, and test lab resources so that these tests can be managed, reported, and traced in an organized and auditable way.

Rational Software Architect Design Manager helps you link the software developed with Rational Software Architect to the test artifacts in Rational Quality Manager and, by extension, to the test execution and results in Rational Test Workbench.

Rational Quality Manager and Rational Software Architect Design Manager are both built on the IBM® Jazz™ platform. The Jazz platform is not a separate product. It is a technology that allows for tight, web-based integration of Jazz-based products and provides some common mechanisms for team collaboration, for example, reviews and comments. Jazz also provides Open Services for Lifecycle Collaboration (OSLC) linking that makes tracing of development artifacts easy to create and navigate.

Rational Software Architect Design Manager helps you and your team to collaborate and manage design information across the application development lifecycle. With Rational Software Architect Design Manager, you can store, share, and manage designs and models in a central location, so you can closely collaborate with stakeholders to successfully meet requirements. Rational Software Architect Design Manager helps improve the quality, time, and agility of software planning, design, and delivery.

Artifacts created in Rational Software Architect can be accessed by the team through Rational Software Architect Design Manager. Because of the Jazz platform these artifacts can be linked to the test artifacts in Rational Quality Manager. With Rational Software Architect Design Manager, artifacts can be traced from development in Rational Software Architect to testing in Rational Quality Manager. The result is higher code quality by showing that each development product is covered by a test case. Because Rational Quality Manager and Rational Test Workbench are integrated, you can see how much of the testing is complete and what the results are. Additionally, since IBM® Rational® Requirements Composer is also a Jazz-based product, requirements created in Rational Requirements Composer can be linked to development artifacts in Rational Software Architect Design Manager. This ability allows you to determine whether all requirements are implemented and to validate that the development artifacts conform to the requirements.

A UML diagram in Rational Software Architect Design Manager with comments and markups is shown in Figure 8.

Figure 8. A Rational Software Architect Design Manager with markups and comments
UML diagram with markups

Click to see larger image

Figure 8. A Rational Software Architect Design Manager with markups and comments

UML diagram with markups

Rational Team Concert helps you collaborate

Integrating Rational Application Developer with Rational Team Concert provides additional capabilities for improving code quality. Rational Team Concert provides collaborative debug and code coverage.

In a collaborative debugging session, you start a session on one machine and then transfer the session and source code to another team member's machine. That team member continues the debugging session. Different team members are experts in different aspects of the code. The most knowledgeable person, the expert, for a piece of code can debug it.

Use the code coverage integration with Rational Team Concert to increase code quality in several ways, including:

  • Sets thresholds for code quality that must be met before code can be delivered to a stream
  • Creates work items for code coverage elements
  • Makes code coverage results for builds visible to your team in Rational Team Concert project areas and downloads code coverage statistics to your workbench
  • Finds related work items for code coverage elements

Color-coded coverage statistics for executed code is displayed in the Rational Application Developer Project Explorer when code coverage is enabled. Color-coded coverage results are displayed for each line of code in the code editor if a code file is opened. Rational Application Developer can also generate a coverage report showing the code elements executed and their coverage results. An example of the results of code coverage and a Code Coverage Report are shown in Figure 9.

Figure 9. Example of a Code Coverage Report
Color-coded coverage results

Click to see larger image

Figure 9. Example of a Code Coverage Report

Color-coded coverage results

Summary

This article presents a quick overview of many of the Rational IDE features that contribute to creating better code. Many tools are available in Rational Software Architect and Rational Application Developer. Sometimes, even experienced Rational users don't realize all of the resources available to them. Each new update to Rational Software Architect and Rational Application Developer brings in new technologies and improved ways to help you.

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Rational software on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=952274
ArticleTitle=Create high quality code with IDE's
publish-date=11122013