Keeping it all Together in .NET

This article was originally published in VSJ, which is now part of Developer Fusion.
Borland’s UML design tool, Together, is available stand-alone and for a range of platforms (JBuilder, Eclipse, WebSphere, SAP NetWeaver, C++ Builder), and it is being increasingly integrated into Borland’s development products such as Delphi. However, Borland’s Together Edition for Microsoft Visual Studio .NET – Together .NET – is especially interesting, because it provides integrated design tools for the de facto standard Windows development environment.

Currently, the only design tool that Microsoft provides is a version of Visio, which isn’t integrated with Visual Studio and runs as a stand-alone diagramming application. While Visio is a very good general structured drawing program, it is a fairly inadequate stop-gap measure as far as a modelling approach to code generation goes. It will reverse engineer a project to create a UML diagram, and it will generate code from a UML diagram. Microsoft has plans for a better system, but it isn’t likely to be available until the release of “Whidbey” in 2005, and “Orcas” a year or two later. What all this means is that Together .NET has a window of opportunity to establish itself as the de facto UML modeller for Visual Studio.

The modelling approach to code generation can be thought of as “flow charts” for the object-oriented age. The basic idea is that you draw a chart using the UML (Unified Modelling Language) symbolism and philosophy. The chart serves to clarify and refine your ideas, to communicate your ideas to others, and even to provide system documentation. Essentially, what the diagram shows is the class structure and relationships between classes. Traditionally a model diagram was translated to code by programmers, but why do things the hard way? As long as the models specifies the class structure accurately, why not use it to generate the code? The one problem with this idea is that the relationship between the generated code and the diagram needs to be “two-way” to keep the relationship up-to-date. Together .NET uses Borland “LiveSource” technology to keep models and code synchronised. This means that you can start from an existing project and generate a model, or create a project’s initial code from a model. After this, changes in the code are reflected in the model, and vice-versa. If you want to adopt UML, then you need a tool like Together to reap the benefits, otherwise you are in a constant state of re-drawing diagrams or re-writing code.

It is important to know that Together .NET only works with C#. This is one area where it isn’t quite as flexible as the Visio approach, which supports code reverse engineering and code generations for .NET projects in C#, VB.NET and C++. However, as long as you’re happy working in C#, Together’s LiveSource and Visual Studio integration are a huge advantage over Visio.

The important additional feature of Together .NET is that it integrates with Visual Studio .NET. Installation is easy, but the product integrates so well that you might not notice that anything has changed when it has completed. A new entry in the Tool menu allows you to configure the way Together works, manage licences, and deal with various aspects of how it works. This is just the tip of the iceberg, and you don’t get to see the rest until you start work on a new C# project, or load an existing project with Together enabled (which is the default setting). The way into Together is via the Model View window, which you can open and dock along with the usual collection of windows on the right of Visual Studio. All help files are displayed as part of the Visual Studio help system.

The Model view is the primary navigation tool, and you can use it to create and manage diagrams via the right-click context menus. A default class diagram is created for the application, and you can add classes or additional diagrams.

Screenshot
A class diagram – easy to use and integrated

This sounds very much like any UML modelling program, but in this case the integration with the development environment is much closer than usual. You can double-click on any element in the Model view window, and instantly be transferred to view its definition in code. The usual Property window also shows properties for diagram elements when they are selected. Within a diagram new elements can be added simply by right-clicking and selecting from Namespace, Class, Interface, Object or Note. Class elements can be edited and created as required, and of course the code is kept up-to-date. Class elements – method, constructor, destructor, field or property – can be added and edited in the same way. Change a method or a property name and the change is made throughout the source code. The Property window can also be used to change class elements and, as you would expect, these changes are reflected in the code and vice versa. However, it is important that you view the “Known issues and Limitations” section of the readme file, to avoid potential problems. For example, if you enter new “fields” in a single line of code e.g. int i,j; then the class diagram will not be updated correctly. Every field should be declared on a separate line (and this is a very reasonable way to write code for readability), but there is no way that Together can enforce this restriction on you.

Screenshot
Creating standard UML diagrams is easy

You can add new diagrams using the right click context menu. Currently supported are the major UML 1.4 diagrams – Class, Use Case, Sequence, Collaboration, Statechart, Activity, Component and Deployment diagram. All diagrams are stored along with the project. You can also create hyperlinks or shortcuts between elements that allow the user to jump from one to another. Hyperlinks between the various types of diagram are useful in creating an easy to understand map of the entire project. For large diagrams the “overview” button in the right of the window provides a thumbnail view that can be navigated using a viewing window selection area. There is no general zoom facility however.

When it comes to documentation, a single click produces an HTML report complete with diagrams, and because of LiveSource it is guaranteed to be up-to-date. The HTML documentation can include a navigation tree to make it easier to browse. A minor problem is that the navigation tree needs the Java virtual machine to work – but it does offer to download it for you.

You can import or export to XMI – (XML MetaData Interchange) – should you want to share your models with a non-Together user. Similarly, you can export diagrams in a range of graphics formats including .BMP, EMF, .GIF, JPG, WMF , TIF and PNG. Diagrams can be customised by setting colour, font and layout, and you can change the view of any diagram by hiding or collapsing aspects of the structure.

The general features that have been discussed so far are common to all of the other versions of Together, apart from the integration features of course. A new idea in Together .NET however is the inclusion of “Patterns”.

Screenshot
Patterns made real

You may have heard of the idea of a pattern in design theory and in this case what is meant can vary from a vague description of “what happens” to a detailed design for a solution to a recurring problem. In this case the patterns are templates that generate diagrams. Together .NET supports templates for classes, links, code, design patterns and so on. Design patterns allow the creation of elements of any type available in the diagram. All patterns are stored as XML files and a pattern organiser allows you to group them according to type. You can create your own patterns, but a set of common patterns are supplied to get you started.

Together .NET has extensive help files, and there are also PDF manuals available for download. There is also a “Getting Started” PDF document, but overall the documentation isn’t likely to be enough if you are a UML/modelling novice, so you may need to get to grips with the basics first via a book or introductory training course. A single sample project is provided, but you have to look in the help file for information on how to work with it and what it demonstrates. The “Getting Started” document takes you step-by-step through another example, but this isn’t provided as a sample project. There is also no attempt to teach you UML or modelling beyond the details needed to make use of Together.

In conclusion, if you want to use modelling with C#, Borland’s Together Edition for Microsoft Visual Studio .NET is a natural choice. It works (and more specifically, it works with Visual Studio), to make modelling as efficient and as productive as it possibly can be. It is highly recommended – try it out for yourself by downloading the Foundation edition from the Borland web site.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The greatest performance improvement of all is when a system goes from not-working to working.” - John Ousterhout