DBMS, September 1996
C/S Developer By David S. Linthicum

The Staying Power of C++

New visual client/server development tools make C++ a cinch.

If you read my column on a regular basis, you know that I'm fond of C++ as a development language. C++, however, got a bad rap as an environment that is difficult to use and requires more time and discipline to build client/server applications. Most damning is its lack of support for RAD. Many people pegged C++ as a tool for building products for mass-market, system-related functions such as device drivers and DLLs, and components (such as ActiveX) for specialized client/server tools.

In reality, C++ and most of the compilers and development environments that support it are still viable for client/server development. C++ tool vendors, such as Microsoft, Borland, and Symantec, took steps to ensure the success of their tools in the client/server marketplace. Additionally, several innovative third-party tool vendors provide products that extend the capabilities of most C++ development environments, including features such as visual development characteristics, the use of components, the correct use of the object-oriented development model, and easy-to-use, built-in database connectivity. This month, I examine two of these products that just hit the market: Optima++ from Powersoft and Visual SQL from Blue Sky Software. Both Visual SQL and Optima++ attempt to make C++ development for client/server a more intuitive process, but they do so in very different ways. Optima++ is a standalone product that uses many characteristics from Powersoft's popular PowerBuilder development environment. In contrast, Visual SQL is an extension of the Microsoft Visual C++ development environment that provides several client/server features, including libraries and components not found in the base Visual C++ tool set.

Optima++
Optima++ is a full-featured visual client/server development environment that can leverage C++ as the underlying development language. Optima++ lets developers use prebuilt OLE automation and ActiveX components within Optima++ applications, and it also supports all that's great with C++ development. Optima++ supports Internet and Intranet development using Java and provides a comprehensive set of wizards to build Java applets quickly. In addition, Optima++ can build server-side Web applications for both Microsoft and Netscape Web servers.

Those of you already proficient with PowerBuilder will find many familiar features in the Optima++ tools. (See Figure 1.) For example, Optima can share DataWindows, reports, and OLE components built with PowerBuilder. In my testing, I could reuse DataWindows from an existing application within Optima++. This feature means that Optima++ will provide the most value for client/server development organizations that already use PowerBuilder. Optima++ supports database manipulation using data-aware bound controls, and the PowerBuilder DataWindows drive database access as they do in PowerBuilder.

Optima++ comes with a copy of Sybase SQL Anywhere, which runs locally inside Windows. This lets you avoid the hassle and expense of purchasing your own database server. Optima++ is a true C++ compiler, and it generates native 32-bit executables for Windows 95 and Windows NT or 16-bit executables for Windows 3.11.

Optima++ Application Development
My first impression of Optima++ was that it was not a typical C++ development environment. Instead, it looked a lot like a RAD tool - that is, until I got to the code. I discovered that there are three basic steps to building an Optima++ application. First, you design and build the user interface by creating any number of forms or windows. On each form, you can place any number of objects, such as text boxes, buttons, or other GUI controls. You access the GUI controls from a palette of controls that are extendible using third-party components such as ActiveX controls.

The Optima++ form design window is easy to use. You simply select tabs on top of the interface designer to access a group of controls. These categories include standard and advanced GUI controls, dialogs, OLE, system functions, database functions, and templates.

Second, you must set the properties for each object on the form. As with other tools, properties control the behavior of the objects (for example, when the button is pushed, do this). Properties also control appearance, including color and fonts. To set properties, simply select an object and click the right mouse button to select the Properties option. For example, to add text to a button, right-mouse-click on the command button and then click on Properties. This displays the properties sheet for the command button. From there you'll find the General pages, where you can click in the Text box to add text for the button. Clicking on OK means you're ready to return to the main menu, and the properties are set for that control.

Third, you must write the C++ code to handle all events that may occur during program execution. You do this by associating objects with code. For example, I created code to retrieve data when a user clicks on a "get data" button. The code editor is easy to use and provides drag-and-drop facilities as well as online help. That's the good news. The bad news is that you really need to know C++ to find your way around this portion of the tool. I suspect that this is where you would spend most of your time. This is an advantage for C++ developers who want to move to RAD tools such as Optima++. However, C++ is in no way an easy-to-use 4GL, and the learning curve may be of concern for those who want a quick move to Optima++ application development.

Adding code is easy, even if coding is not. For example, to create code that responds when the user clicks on a button, simply select the right mouse button again; this time, point to Events. Select the Click menu item, which opens a code editor window for the Click event. Now enter the code to let Optima++ know what to do when that particular event occurs.

The drag-and-drop programming capabilities mean that you can drag the object that you want to control from the form design window to the code editor window. This opens the reference card, which displays information on the actions you can perform on that object/control. Selecting any action from the Reference Card opens a Parameter Wizard, which helps you express actions in C++ code and pastes the appropriate code into the code editor window automatically.

Once you're happy with the application, a simple click on the Run button will compile and start the program. That compiler - proven Watcom technology - is the executable native to your 16-bit and 32-bit Windows clients.

The component development subsystem found in Optima++ is well thought-out. Optima++ provides a set of prebuilt components that exist in the Optima component library. Developers can find most of the components they need for their applications, such as menus, check boxes, buttons, and list boxes. Optima++ gets its components from Gamesman OCX (created by Steven Gamesman, now called ActiveX) components. These components are royalty-free and have several handy controls, including a calendar control and an alarm clock. This saves you the time and trouble of locating and integrating third-party OCX components (which are also an option). In addition, you can find and use non-visual components such as timers, threads, and semaphores. Optima++ binds its component model to the object-oriented model of C++, and thus an object is an instance of a component. A component is functionally equivalent to a class. Once I made that connection, things got easier.

Visual SQL
Visual SQL is useful for Visual C++ developers who want to augment the client/server development capabilities of Visual C++. As I mentioned previously, Visual SQL simply adds some neat client/server tricks to Microsoft Visual C++; you'll have to own and know how to use Visual C++ before you can take on Visual SQL application development properly. However, you can build client/server applications much faster with Visual SQL than with Visual C++ alone. Visual SQL layers nicely into Microsoft Visual C++ and Developer Studio, using native wizards to generate MFC libraries for client/server applications. Visual SQL also includes several new client/server-enabled components. Like Visual C++, Visual SQL is an ODBC-only tool that lets you connect to most databases.

Visual SQL features a design environment that extends the capabilities of the Visual C++ AppWizard by providing components built for client/server development. Like other Visual C++ AppWizards, Visual SQL's version of the AppWizard lets you answer a series of questions, and the base application emerges as a complete application with the database connections and data windows already in place. The AppWizard includes links to the ODBC Manger, Query Builder, SQL Wizard, and SQL Editor.

Visual SQL also comes with a Data Screen Wizard that leads you through the process of creating forms and windows to display the data. By default, the Data Screen Wizard provides menu items for database navigation. There is a Datasheet Wizard as well. The Fill Pick List Components let you fill a combo box or list boxes with data from the database server. The Pop-up Pick List Component creates a member function that lets users select a value from a pop-up dialog box and passes it back to the application. The SQL Statement Function Component lets you create a member function that invokes SQL statements.

Visual SQL also provides an Extended Class Wizard contained within the Developer Studio. The Extended Class Wizard offers more than 50 dialog data exchange (DDX) and dialog data validation (DDV) functions that let you transfer data between variables and controls. Finally, an Application Browser provides a simple way to examine how your Visual C++ application utilizes the database objects (such as data sources, tables, views, queries, and SQL statements).

The Database Explorer is accessible directly from Visual C++. This tool includes a browser utility to examine SQL queries and results sets as they return from the database server. The Database Explorer also provides easy access to visual development tools such as Connection Manager and SQL tools. Visual SQL includes testing tools as well. The Visual SQL Configuration Tester verifies that your machine is configured correctly for database connectivity. The ODBC Source Tester verifies that the ODBC data source is configured correctly.

Visual SQL Applications
Building client/server applications using Visual SQL and Visual C++ is an interesting experience, especially if you are already a Visual C++ developer. First, create the database or link the application to an existing database. You do this by creating a connection between Visual SQL and the target database, defining the ODBC data source, and then creating a connection using the Database Explorer.

The next step is to create your application framework using Microsoft Developer Studio, which works with Visual SQL. As I mentioned previously, you create your framework using the AppWizard extended with Visual SQL capabilities. The Visual SQL AppWizard creates the main screens and classes for an MDI, SDI, or dialog-based application. In addition, the Visual SQL AppWizard creates an initial menu that includes basic Windows commands as well as database functionality.

After answering all of the questions in the AppWizard, you will have a complete but basic client/server application. The application can connect to the target database, display data, and update the database. AppWizard automatically generates the classes you need to support the application.

Of course, the generated application probably doesn't meet the exact requirements of your application. To solve this problem and extend the generated application, you can use the Visual SQL tools and Visual C++. Here you can use some of the components that come with Visual SQL, found in the Component Gallery within the Microsoft Developer Studio. Or you can drop back to the Visual C++ environment for further customization. Compiling the application is typical Visual C++, and you'll find Win32-based application development support for Windows 95 and Windows NT.

Two for the Road
This is not really a comparison of these two products. Each uses its own architecture and solves its own set of problems. I see Optima++ as a great C++ development environment for existing PowerBuilder shops that want an easy way to join the C++ crowd and take some of their existing PowerBuilder applications along for the ride. Optima++ brings rapid client/ server database application development to C++, and it also offers a guide path to the Web. In my opinion, its best asset is its ability to create true 32-bit native executables that work well on low-powered computers.

I don't, however, see anything in Optima++ that you can't find in other client/server tools such as Delphi or PowerBuilder. Moreover, you'll have to learn C++ to make your applications sing and dance, although Optima++ does a good job of guiding you through the complexity of the language. Visual SQL is a must for those of you who want to mix client/server application development and Visual C++. It adds the additional libraries you'll need to generate data-aware objects, and it has client/server components that add value to the Visual C++ components gallery.

Visual SQL is not a substitute for good C++ application design and development, however. You'll have to learn the ins and outs of Visual C++ to extend its base capabilities to meet most application requirements. It's amazing how resilient C++ continues to be in the world of client/server, where RAD, 4GLs, and the Web drive development. New tools such as Optima++ and Visual SQL are indications that C++ will be a part of mainstream client/server development for some time.

FIGURE 1


--Those of you who are already proficient with PowerBuilder will find many familiar features in the Optima++ tools. For instance, Optima can share DataWindows, reports, and OLE components built with PowerBuilder.


David S. Linthicum is a technical manager with EDS in Falls Church, Virginia. He's the author of several books on software development, a speaker, and an associate professor of computer science at a local college. You can reach David via email at 70742.3165@compuserve.com, or visit his home page at http://ourworld.compuserve.com:80/homepages/D_Linthicum/.


* Blue Sky Software Corp., 7777 Fay Ave., Ste. 201, La Jolla, CA 92037; 800-677-4946, 619-459-6365, or fax 619-459-6366; http://www.blue-sky.com.
* Powersoft Corp. (a subsidiary of Sybase Inc.), 561 Virginia Rd., Concord, MA 01742; 800-395-3525, 508-287-1500, or fax 508-287-1600; http:// www.powersoft.com.

Table of Contents - September 1996 | Home Page
Copyright © 1996 Miller Freeman, Inc. ALL RIGHTS RESERVED
Redistribution without permission is prohibited.
Please send questions or comments to mfrank@mfi.com
Updated Wednesday, September 18, 1996