Getting Started with VisualAge C++

From EDM2
Jump to: navigation, search

by John Robertson

VisualAge C++ Version 3.0 is the follow-on product to IBM's C Set++ Version 2.0 and makes several advances over the previous product. VisualAge C++ is an integrated development tool set, featuring IBM's C/C++ compiler, IBM's Open Class Library, the Developer's Toolkit for OS/2 Warp, and the following tools all integrated into one easy-to-use package:

  • VisualAge C++ Visual Builder
  • VisualAge Editor
  • VisualAge Debugger
  • VisualAge C++ Browser
  • VisualAge Performance Analyzer
  • VisualAge C++ Data Access Builder

In addition, VisualAge C++ integrates all these tools with IBM's WorkFrame, which allows seamless tool-to-tool communication and project configuration and management. VisualAge C++ also supports powerful direct-to-SOM development.

Installing VisualAge C++

The installation procedure for IBM C Set++ Version 2.0 was difficult for some to work with because it required four separate installation programs. The VisualAge C++ Version 3.0 team listened to its users and made the installation program much easier to use. Using IBM's Software Installer/2 program, the installation is as simple as inserting the CD-ROM, indicating where you want to install, choosing your options, and letting it go to work. VisualAge C++ Version 3.0 also supports shared installation, either across a network or from the CD-ROM. This lets you keep the bulk of the product, such as samples and documentation, off your hard disk.

For users of C Set++ Version 2.0, the new installation procedure for Version 3.0 will be a very pleasant surprise. (Note: You can use the complimentary version of Software Installer/2 on this volume of the Developer Connection to create an easy installation program for your product!)

Migrating Your Code

If you have been using VisualAge C++, most likely you have existing C or C++ code that you want to keep. VisualAge C++ provides excellent support for migrating existing code.

If you have been using WorkFrame Version 1.x or 2.x, you can migrate your projects with the WorkFrame Migration tool (the Migration Tool can be found in the Tools folder of the VisualAge C++ folder).

To migrate code not already defined in WorkFrame projects, you can use the VisualAge C++ Project Template (also found in the VisualAge C++ folder). Drag the template onto the desktop or folder just as you would any other template, then open the new project's Settings view. To encapsulate code, simply tell the project where the code resides and what default actions you want in the project. Using the default actions will be sufficient in most cases, although you can define your own actions and tool associations easily. The concept of Action Profiles, which was prevalent in C Set++ Version 2.0, has been eliminated, making the use of WorkFrame's powerful actions simpler to configure.

Setting Up New Code

IBM has long been known for shipping some of the most comprehensive sets of samples on the market, and VisualAge C++ is no exception. In this release, the extensive sample set has been shipped as WorkFrame Projects. With the samples set up as projects, you can exploit the usability of the project while learning from the sample code, building with a simple button click, editing files simply by double-clicking on them, or browsing with a simple action from a pop-up menu.

Perhaps the greatest improvement to VisualAge C++ Version 3.0 for new users is the Project Smarts tool, which lets you set up a new project quickly and easily. To use the tool, you select a project type (such as a Visual Builder application, Data Access application, or a Presentation Manager application) to set the tool in motion. The tool starts working, asking for information along the way, such as the name of the new project and where you want the source code copied. When the tool is finished, a complete project is available for you to get started on, complete with stub files and ready to compile. Some of VisualAge's key competitors score points with customers by allowing them to install the package and compile a working graphical user interface (GUI) application within minutes - now VisualAge C++ does that as well.

By using Project Smarts, the WorkFrame migration tool, Project Templates, or copying an existing sample, setting up projects in VisualAge C++ is far easier than ever before, and gets you up and running quickly.

Figure 1. The Project Smarts tool lets users of VisualAge C++ set up a variety of project types quickly and easily. Users can also define their own prototype projects and include them in Project Smarts.

Building a Production Application with VisualAge C++

Now let's walk through the creation of an application using VisualAge C++, from the creation of the initial code to the production of the finalized application - in this example, a GUI-based, data-access application. Since you're starting from scratch, the first step is the creation of the project. Using Project Smarts, select a Visual Builder application. This option creates the project and also the initial Visual Builder "part" that you'll use to create the customized GUI. When the Project Smarts tool has completed its work, you have a project folder.

Opening the project, you see a single file - the Visual Builder Part. The first step is to define the user interface. Open the part by double-clicking, or select Visual from the pop-up or the Selected menu, to activate the Visual Builder and load the part. Once the part is open, you'll see that Project Smarts has already done a great deal of work. The project already contains a frame window part, complete with canvas, menu bar, standard menu pull downs, some push buttons, and standard help functions (a help window is also enabled). For simple GUI applications like this one, you will usually not need to do much more than customize the menu bar and the client area for your application's special needs.

To add user interface parts to the application, drag parts from the part palettes to the appropriate place in the Composition Editor. Everything on the screen is a separate object-oriented part, and customizing the application is simply a matter of changing Settings.

Figure 2. The VisualAge C++ Visual Builder is based on IBM's popular VisualAge for Smalltalk product. Users construct their user interface using reusable "parts," and then generate C++ code, which IBM's compiler can then optimize, producing executables of considerable speed while cutting down on GUI development time.

Once the GUI is built with the Visual Builder, you merely generate the C++ code and click on either the Build button in the WorkFrame project or select Build from the Project pull down. The application is compiled and linked. The new integration of the Visual Builder and WorkFrame makes the iterative creation of a GUI simpler than ever before.

The visual aspects of a program are not the only thing that you can create with the Visual Builder. Using the Part Interface Editor and the Class Editor, you can specify the way the parts will behave once they are generated into C++ classes. The Visual Builder also lets you customize more than the visual appearance of an application. By creating non-visual parts, you can define a great deal of the application's "back-end" behavior.

The Data Access Builder

Now let's say you want to access data in a DB2 table with your application. To do so, use the Data Access Builder, which lets you create C++ classes or Visual Builder parts that allow access to database tables. Starting the Data Access Builder is simple using WorkFrame, and using it is simple as well. Specifying the table name and the key fields, you create the parts of classes in a graphical building environment, changing settings by pointing at an object (just as you would in the Workplace Shell or with WorkFrame). In this case, you will create a Visual Builder part, which is imported into the Visual Builder as a non-visual part.

The Editor

The VisualAge Editor is a highly customizable, live parsing editor. It formats language elements with colors and fonts for improved readability and error detection. In addition to supporting C and C++, the Editor supports over 20 other languages, and has pre-made key emulations for four other editors.

Figure 3. If a build has a compile error, the user simply clicks on the error in the project's monitor area. The Editor opens at the appropriate place with the error embedded in place.

As well as being highly customizable, the Editor is completely integrated with VisualAge as a whole. The Editor can be launched from any tool whenever text editing or display is appropriate. It is closely tied with the project's monitor pane, and lets you double-click on any compiler error to be taken right to the error in the appropriate file. Similarly, while in the debugger, double-clicking on white space in any source view will take you from the debugger to the Editor. In addition, the Editor and most other tools are highly integrated with the VisualAge C++ information. If you highlight a language token, such as an IBM Open Class name in the Editor, and type Ctrl+H, the documentation for that class will be displayed. In addition, the VisualAge C++ online help and documentation are available from all of its help pull downs, so you can get information anywhere you need it.

Once you have built your application and it is compiling without errors, you can run it by double-clicking on the executable object. If the executable requires debugging, compiling for debugging is simple. Rather than dealing with individual compiler flags, you can compile for debug by choosing the Compilation for Debug option in the Build Smarts of the project and then clicking on the Build button. All of the common compile options are available in Build Smarts, including debugging, browsing, profiling, and optimization. To manipulate the individual compiler flags, change the settings in the compiler and linker actions (much like C Set++ Version 2.0).

The Debugger

Selecting Debug from the executable object's pop-up launches the VisualAge Debugger, a powerful multi-threaded debugger for OS/2 applications. The VisualAge Debugger is more powerful than ever, offering multiple views of a program in execution, with a unique notebook-like view for multiple source files.

The Browser

If you want to browse the classes and member functions of your applications, VisualAge C++ comes with the new and improved C++ Browser. Users of C Set++'s Browser will be pleasantly surprised with the improvements in the VisualAge C++ Browser. In addition to supporting quick parsing of files not compiled for the Browser, the Browser has a simpler, more object-oriented user interface that lets you browse classes or functions via their pop-up menus. In addition, the Browser comes pre-configured to browse the Class Libraries that come with VisualAge C++, so the libraries are easier to understand than ever before.

The Performance Analyzer

If you want to examine your program's execution in detail, you can use the VisualAge Performance Analyzer. It monitors executables at run time, generating execution traces. You can view these traces in any of five graphical views that highlight the inner workings of the program. You can see which modules/functions use up most CPU time and the exact sequence of program execution and thread switching.

Once you're satisfied with your application and its performance, use Build Smarts to build and produce the final executable code.


VisualAge C++'s integration of visual building, integrated tools, increased usability, and IBM's world-class compiler and class libraries make VisualAge C++ the ideal platform for OS/2 development. Whether you are maintaining a current set of OS/2 applications or starting from scratch, VisualAge C++ provides excellent support for you, and quickly gets you set up and productive.

Reprint Courtesy of International Business Machines Corporation, © International Business Machines Corporation