By: John Kaster
Abstract: Read about some of the Together features for Delphi and C# in Borland Developer Studio 2006
Model navigation to code
Audits and Metrics
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.
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.
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.
When you click the Model view tab, the IDE will confirm that you want to enable modeling for that project with the following dialog.
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).
Double clicking on Complex (highlighted in the diagram above) brings up the LiveSource model of your application.
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.
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.
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.
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.
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.
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.
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.
Now, after hitting Start again, I see more of the audits I really care about:
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.
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.
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.
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.
Navigation through analyzed symbols is supported. You can also toggle the visibility of various items, such as namespaces.
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.
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.
If you don't understand what a specific metric is for, you can view the description of it to get the explanation.
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.
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.
Together also provides document generation for both Delphi and C# projects. Any Delphi or C# project can be documented with Together.
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.
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.
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.
Your documentation set could end up being quite large, so the message window displays the status of the document generation as it is running.
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.
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.
Download Delphi XE8 now!
Get Free Trial
Webinars on demand!
More social media choices:
Delphi on Google+
@RADTools on Twitter
Server Response from: ETNASC03