RAD Studio 2010 UML and Audits and Metrics: not the old UML!

By: Michael Rozlog

Abstract: Understanding the UML features in RAD Studio 2010, Delphi 2010, and C++Builder 2010

By:      Michael Rozlog

           Sr. Director of Delphi Solutions

Date:   Friday, September 11, 2009



    What is included in RAD Studio 2010?

As most developers know, RAD Studio, comes with both C++Builder and Delphi. The UML and static analysis features have been added to all levels of the product, so if you are using Delphi 2010 or C++Builder 2010 Professional, Enterprise, or Architect you will have access to some if not all the UML features in the product. For Delphi 2010 users, audits and metrics have been added to each level of the product, so even users of our Professional level products get some of the advanced features.

Below is a simplified list of features included in RAD Studio 2010:

Personality:
D=Delphi
C=C++Builder
P=Delphi Prism

Architect

Enterprise

Pro

UML Modeling

UML Code Visualization—at any time, get a UML model view of your source code

C D

>>

>>

>>

Diagrams have an updated look and feel

C D

>>

>>

>>

Sequence diagrams

C D

>>

>>

Collaboration diagrams

C D

>>

>>

State charts

C D

>>

>>

Deployment diagrams

C D

>>

>>

Use case diagrams

C D

>>

>>

Activity diagrams

C D

>>

>>

Component diagrams

C D

>>

>>

Documentation generation

C D

>>

>>

80+ Code Metrics that allow for deep understanding and static analysis of the health of the object domain

D

>>

>>

Introduced for Delphi Professional in 2010! 10+ introductory level code Metrics for understanding the health of the object diagram

D

>>

200+ Code Audits for deep code analysis to better understand the coding style and approach

D

>>

>>

Introduced for Delphi Professional in 2010! 10 introductory level code audits for better code understanding

D

>>

Import model from Rational® Rose (mdl import)

C D

>>

Language neutral UML 1.5 and 2.0 modeling

C D

>>

Transformation from language neutral UML 1.5 and UML 2.0 projects to source code projects

C D

>>

Design Patterns support, including GOF patterns

C D

>>

>>

Custom design patterns support

C D

>>

>>

Diagram printing

C D

>>

>>

>>

XMI 1.1 Import/Export

C D

>>

>>

OCL 2.0 support

C D

>>

>>

>>

"UML in Color" profile

C D

>>

>>

>>

Diagram hyper-linking and annotations

C D

>>

>>

>>

    Is this the same UML features from years past?

The short answer to that question is NO. It is still based on the same technology, but many, many, upgrades have occurred to make the product faster to load, faster to reverse and forward engineer, and presents a much more modern look. The same benefits of these tools still hold true today, that they help developers get more done in a shorter amount of time.

Today Delphi and C++Builder users can reverse engineer a class diagram at any time in all levels of the product.

Hide image
Click to see full-sized image

In the enterprise and above, developers can make changes to the code or model and both will be kept in synch with each other. So if the developer would right-mouse click on the above diagram and adds a Class, the code would also be generated in the unit for that class. This 2-way capability, a feature called LiveSource™, makes adding anything to the class diagram, and ultimately your code, as simple as a right-mouse click to the context menu shown below.

Hide image
Click to see full-sized image

    What is Pattern Support?

As you can see from the above, the UML integration allows for support around Pattern, so if you want to create a GOF Singleton pattern, click the Create by Pattern… menu item and select it from the included patterns in the product:

Hide image
Click to see full-sized image

Click the Ok button and the pattern will be added to the model and corresponding code will be generated.

    A full UML product…

In the Enterprise edition and above, developers have full UML integration meaning they can create any of the standard UML diagrams.

Hide image

For those not familiar with what each diagram is really responsible for, the following is a list:

  • UML – Activity Diagram Definition
    A diagram showing the step-by-step workflow of components in a system.
  • UML – Class Diagram Definition
    A diagram showing the step-by-step workflow of components in a system.
  • UML – Use Case Diagram Definition
    A high level graphical representation of functional requirements.
  • UML – Component Diagram Definition
    A diagram used for showing physical components and their dependencies.
  • UML – Collaboration Structure Diagram Definition
    A diagram that shows the internal structure of a class and its collaborations.
  • UML – Deployment Diagram Definition
    A diagram for showing the hardware and its deployed components.
  • UML – State Machine Diagram Definition
    A diagram that shows the different states/transitions an object.
  • UML – Interaction (Sequence and Communication) Diagrams
    Diagrams that show Message Sequence and or interaction between objects and the sequences of messages.

Today, when it comes to support for UML, RAD Studio is making key technologies available to developers to help them communicate better, create better designs quicker, have the ability to set coding standards, and check the health of a Delphi application. Plus, it also supports automatic Documentation Generation, which all developers like.

RAD Studio 2010 Architect adds support for both types of diagrams; ones based on source code and the other based on design. An example of a diagram based on source would be a Class diagram, which uses the LiveSource™ engine to automatically keep the code and model in-synch at all times. Whereas, a language neutral design is only based on the UML specification and no code is generated or needed. The tool also includes the ability to take these language neutral designs and generate source code for the designs, which gives the best of both worlds; the ability to create great object models, and if code is needed it can work with that just as easily.

This is a great time saver and adds significant piece of mind knowing that when a change is made in either the code or the model, that both areas will be up-to-date. A design diagram (with no source code dependencies) would be a Use Case; this communicates high-level functional requirements graphically.

Hide image

    RAD Studio 2010 UML integration easy to use:

RAD Studio 2010 makes it extremely easy to use UML and takes advantage of the advanced tools. First, either start with a new project like you would normally do, or open up an existing project. Once the project is open click on the Model-View tab under the project manager or Project|Model Support menu item.

Hide image
Hide image

Clicking either of these on the open project will activate the UML integration and present a new dialog:

Hide image

Simply click the Yes button and you’re on your way. This will then open the design surface and will use the LiveSource™ technology to reverse the project and give you a Class diagram as shown above. Again, any changes made in the model will be reflected in the code, so if you change the model, like a string attribute to a new name, that name will now be in the code as well.

From this point you can add more objects, setup associations, aggregations, and all things object oriented. You can also add new models to the project and these industry standard diagrams, including use case diagrams, class diagrams, and sequence diagrams, etc., to help developers using UML to communicate.

    Introduction to Metrics:

The Delphi 2010 part of RAD Studio also brings more than simple modeling to the tool. You can use Delphi 2010 to analyze your existing projects, and generate metrics and audits that you can use to uncover potential problems with your applications. For example, the following figure shows a generated Kiviat chart. A Kiviat chart depicts a best practices circle. Points that are within the inner circle are considered acceptable, and those outside denote areas that may deserve your attention.

For example in the graph shown here, the depth of inheritance hierarchy (DOIH) appears outside the user defined inner circle. This metric indicates that one or more of your classes are abnormally deep, with respect to the root class (Object or TObject).

Hide image
Click to see full-sized image

You set the limits for the metrics used by Metrics. The following figure shows the QA Metric dialog box where these metrics are configured.

Hide image
Click to see full-sized image

Delphi 2010 covers the major areas of Metrics, with over 10+ included in professional and 80+ in the Enterprise and above. Below is a high-level table of which ones are included:

Basic

Inheritance

Cohesion

Inheritance-based coupling

Complexity

Maximum

Encapsulation

Polymorphism

Halstead

Ratio

    Introduction to Code Audits:

The use and configuration of audits is similar to metrics. The following figure shows the QA Audits dialog box, which contains the audits equivalent to the QA Metrics dialog box.

Hide image
Click to see full-sized image

Delphi 2010 covers the major areas of Audits, with over 10+ included in professional and 200+ in the Enterprise and above. Below is a high-level table of which ones are included:

Arrays and References

Design flaws

Branches and Loops

Expressions

Coding Style

Naming Style

Declaration Style

Performance

Duplicated Code

Portability

Superfluous Content

Possible Errors

The static analysis using code Audits will look at every single line of every single method of every single class, or every single namespace, and generate a list of faults that you define. This helps with poor code and refactoring.

Hide image
Click to see full-sized image

    Automatic Documentation Generation:

One of the other major features found inside the UML integration is automatic Documentation Generation. Notice in the below figure that complete developer documentation has been produced by a simple click of a menu item.

Hide image
Click to see full-sized image

These advanced tools really help all of the developers out there, from the Architects to the newbie just starting with RAD Studio 2010. The advanced tools like LiveSource™ to keep the code and model in-synch, and the ability to generate new models for better communications, is great. It is also nice that advanced tools like static Code Audits and Metrics are available, especially if large amounts of code is being inherited or a team wants to know where the code really is as far as health and standards. Finally, the ability to generate the documentation with hyperlinks, which links the various models together, is a real time saver and allows developers to keep up-to-date with a click of the button.

Server Response from: ETNASC01