Together features in Delphi 2006 and C#Builder 2006

By: John Kaster

Abstract: Read about some of the Together features for Delphi and C# in Borland Developer Studio 2006

Table of Contents

Overview

LiveSource modeling

Model navigation to code

Audits and Metrics

QA Audits

QA Metrics

Metric description

Kiviat Chart

Document Generation

Conclusion

One of the most anticipated features for the latest release of Delphi is support for the Delphi language with Borland's Together technology. Together includes UML modeling, source code development, maintenance, and management features for both Delphi and the C# language inside Borland Developer Studio.

    Overview

Together has features that break down into five major functional areas in this release of Delphi.

New LiveSource Class diagramming, with two-way modeling – changes in code reflected in the model and vice versa

New UML Diagram suite, including Class, Use Case, Sequence, Collaboration, State Chars, Deployment, Activity, and Component Diagrams

Design Patterns to help you get started quickly with industry recognized GOF (Gang of Four) design patterns and more, or add your own.

Refactorings to improve your existing code without breaking it

Audits and Metrics to help you gain insight into your source code

Document Generation to automatically generate professional quality documentation from your source code and models

In this article, I'll briefly introduce LiveSource, Audits and Metrics, and Document Generation. If you would like to watch what you can do with Together in Delphi, watch the BDNtv episode Overview of Together in Delphi 2006.

    LiveSource modeling

You can start with any existing Delphi or C# project to quickly see what LiveSource can do for you. When you open your project, it will not have modeling support enabled by default. If you click the model view tab, which is the tab after the project manager, as shown below.

Hide image
Click to see full-sized image

When you click the Model view tab, the IDE will confirm that you want to enable modeling for that project with the following dialog.

Hide image
modelsupport

After you answer "Yes", you can see the model-oriented view of any project in your project group that has modeling support enabled. I have navigated down into this Delphi Win32 project so you can see how the model view is organized by namespaces (and other models you might have in the project).

    Model navigation to code

Hide image
modelview

Double clicking on Complex (highlighted in the diagram above) brings up the LiveSource model of your application.

Hide image
Click to see full-sized image

The very small image in the bottom right is the Overview of the entire model. This Together feature allows you to quickly select your specific view, based on your current display size, out of everything on your diagram. This is a very convenient navigation feature when your models are large or your display resolution is small.

Hide image
modelcontextmenu

From any item in the diagram, you can bring up the context menu synchronize the model view tree node with the active item, go to the definition of the item in the source code, create reusable patterns (from multiply selected items), perform refactorings, and so on.

    Audits and Metrics

Together has very sophisticated source code analysis capabilities that do not require running the application to perform the analysis. This static code analysis is based on detailed examination of all the source files you tell Together to analyze.

Hide image
Click to see full-sized image

You can select the scope of your analysis from the model view by right mouse clicking on the name space you want to analyze. The context menu is displayed above. We'll select QA Audits first.

    QA Audits

When you select QA audits, a dialog appears that provides both information and options for running your audits. There are several categories of audits, Arrays and References, Branches and Loops, Coding Style, Declaration Style, Design Flaws, Duplicated Code, Expressions, Naming Style, Performance, Possible Errors, and Superfluous Content.

Each of these categories has specific audits underneath it. You can toggle the use of an entire category, or specific audits within a category. If some of the audits in a given category are off, the category will be displayed in gray, as Coding Style is in the screen shot below. Once you have selected the audits you want to use, you can save that as a profile to use at any time in the future.

Hide image
Click to see full-sized image

Displayed in the screen shot above is the description of the AIOR audit condition, or "Array Index is Out of Range." It describes code that will flag the audit condition, and also shows an example.

After you select the audits you want, you can hit the Start button and have the selected code (or entire application) analyzed.

Hide image
Click to see full-sized image

After the audit run is completed, the results are shown in the message pane inside the IDE. Each audit condition, the title of it, its severity, the "Resource" or compiler symbol referenced, the source file, and code line are all listed in the results pane. You can jump directly to any auditing issue by double clicking on the audit.

Looking at the results above, I noticed an audit I'd like to turn off – the "Use Camel casing" audit. So, I'll click the "restart" button (the bottom button on the left side of the Audits pane) and turn off the "Naming Conventions" audit, as shown below.

Hide image
Click to see full-sized image

Now, after hitting Start again, I see more of the audits I really care about:

Hide image
Click to see full-sized image

You can also save the results of your audits to an XML or HTML report by using the top left button on the Audits pane, or view the description for any audit by right mouse clicking on the audit and selecting Show Description. By using the buttons and context menu on the Audits pane, you can iteratively improve your code and re-run the audits without having to move all around the IDE.

    QA Metrics

Metric analysis of software is part of a good software engineering practice, as explained by Karl Weigers in this primer, and at the 2003 Borland Developer Conference in San Jose.

Hide image
Click to see full-sized image

Code metrics can get quite complicated in the analysis phase, so expect to see a progress dialog when metrics are being run on your source code.

Hide image
metricprogress

After we're done with the metric analysis, the Metrics pane gets added to our message view, and we can toggle the visibility/granularity of the items we want to see in the metrics report.

Hide image
Click to see full-sized image

Navigation through analyzed symbols is supported. You can also toggle the visibility of various items, such as namespaces.

Hide image
Click to see full-sized image

If you see anything in red, that means you might have issues with your code. To find out more about the metric outside the normal bounds, you can right mouse click to view the description.

    Metric description

The metric in the screen shot above, is abbreviated as RFC, which is short for Response For Class. The description of this metric is shown in the screen shot below, which was displayed in the IDE after right mouse clicking and selecting the "Open" menu item shown above.

Hide image
Click to see full-sized image

If you don't understand what a specific metric is for, you can view the description of it to get the explanation.

    Kiviat Chart

A convenient way of visualizing the status of your source analysis is with a Kiviat graph. A Kiviat chart can be automatically generated from Together.

Hide image
Click to see full-sized image

The Kiviat chart shown in this figure shows the vectors used for the analysis, and data points outside of the red circle correspond to the values listed in red in the table at the bottom of the screen shot.

    Document Generation

Together also provides document generation for both Delphi and C# projects. Any Delphi or C# project can be documented with Together.

Hide image
Click to see full-sized image

Here is part of a model that will be used to generate documentation for the Borland Data Provider interfaces. The documentation wizard is available from a right mouse click on the relevant node in the Model View.

Hide image
docgendialog

The level of granularity for the documentation can be selected for every document generation. The documentation can include a navigation tree and UML diagrams. The browser can be automatically launched after documentation is generated.

Hide image
Click to see full-sized image

Document generation is not a two-way process. All existing documentation in the target directory gets overwritten. The focus on documentation should be in putting the information directly into the source code or model for the document that will be generated. Source code comments can be extracted and put directly into the documentation in the appropriate place.

Hide image
Click to see full-sized image

Your documentation set could end up being quite large, so the message window displays the status of the document generation as it is running.

Hide image
Click to see full-sized image

Finally, when the document generation is complete, the browser can be automatically invoked so you can view the results of the documentation, and navigate through the diagram, the navigation tree, and hyper links automatically embedded into the document for you, as shown in the screen shot above.

    Conclusion

There is much more that Borland's Together technology provides to software engineering practices, and the links provided in this article are an excellent place to start learning more. The Together interface in Borland Developer Studio 2006 is a great performance (and feature) improvement over what was offered in Delphi 2005. Even if you looked at Together in Delphi 2005, you should look again. It is much more powerful and responsive than it has been in any previous C#Builder or Delphi IDE.



Server Response from: ETNASC04