Rapid Application Development with Visual FoxPro 3.0

Jon Sigler

September 12, 1995

Developers can target Windows, Windows 95, and Windows NT

Microsoft Visual FoxPro 3.0 is a relational database management and development tool that allows developers to create applications on any Windows-based 16-bit or 32-bit operating system—Windows, Windows NT, or Windows 95. Applications created with Visual FoxPro on any of these operating systems will look and run the same on the others without code changes. This means that developers don't have to worry about which operating system their clients are using.

Visual FoxPro complies with the Windows 95 logo requirements, so applications written in Visual FoxPro are eligible for the seal.

Visual FoxPro also gives users direct access to Microsoft BackOffice server components such as SQL Server 6.0, allowing developers to build enterprise-wide, client-server applications.

Object-oriented extensions

Visual FoxPro provides a visual, object-oriented development environment and supports rapid application development through its rich object model, which includes a complete set of base classes and support for inheritance, subclassing, polymorphism, and encapsulation.

Object-oriented programming is based on two fundamental concepts: objects and classes. Instead of thinking about program flow, developers deal with objects—self-contained application components that have private functionality as well as functionality that developers can expose to users. A class is the blueprint of an object, that is, it contains information about how an object should look and behave. In Visual FoxPro 3.0, you can create classes using the following syntax:

DEFINE CLASS Classname1 AS cBaseClass

[[PROTECTED PropertyName1,PropertyName2...]

PropertyName = eExpression...]

[[ADD OBJECT [PROTECTED] ObjectName AS

ClassName [NOINIT]

[WITH cPropertylist]

[[PROTECTED] FUNCTION/PROCEDURE Name

cStatements

[ENDFUNC/ENDPROC]]

ENDDEFINE

You can also create a class visually, using the Class Designer, as discussed below.

The Visual FoxPro object model

The Visual FoxPro 3.0 object model supports features of object-oriented programming such as inheritance, subclassing, encapsulation, and polymorphism.

Inheritance. A newly created object can inherit characteristics (properties and methods) from its parent ("template"), thus eliminating the need for duplicate code. A developer can also override the inherited characteristics to customize an object for specific use. Visual FoxPro 3.0 fully supports inheritance and overrides either syntactically (through code) or visually (through the design interface).

Subclassing. A newly created class can also inherit characteristics from a parent, thus becoming the subclass of its parent class. Subclassing allows users to create libraries of reusable classes with very little or no new code. Subclassing also allows the easy addition of new functionality to a group of objects: A developer simply introduces the functionality once in the parent class, and all derived child classes inherit that functionality automatically.

Encapsulation. Object-oriented programming allows developers to package attributes (properties) and behaviors (methods) together within an object. In Visual FoxPro, you can package information about an object so that the information can be accessed only through specific interfaces. This allows you to hide the details of internal implementation and management from users, while supplying the object itself with all the information it needs to know.

Polymorphism. Visual FoxPro 3.0 supports polymorphism, which allows a specific function to change its behavior, depending on the circumstances. For instance, an arbitrary DRAW method can behave differently, depending on the object (for example, a square or circle) that invokes it. This dynamic binding of functionality allows users to create structured class hierarchies, where the basic skeletons of objects are defined in the base class, and specialized code is defined in the derived subclasses.

Event-driven application development

Traditionally, Xbase has required users to either write their own handlers to process a limited set of events or to rely on READ, a wait state that simulates event handling by the system. With Windows, the number of events users may want to access has increased; consequently, event handling has become more complex.

In Visual FoxPro 3.0, users can still fully devise their own event-handling scheme or rely on READ, but, by default, the system (rather than the users) handles object events. Furthermore, the user can now fully access the standard set of Windows-based events (for example, mouse movements that enable the dragging and dropping of objects). Additionally, the FoxPro language for accessing objects has been updated to adopt the standard syntax object.member (where member can be a property or event), which promotes consistency with other Windows-based, event-driven development environments.

Visual design tools

The FoxPro visual design tools, which are geared toward increasing developer productivity, have been enhanced in version 3.0. These tools include the Project Manager, the Database Designer, the Form Designer, and the Class Designer.

The Project Manager in Visual FoxPro 3.0 combines the functions of the FoxPro 2.6 Catalog Manager and Project Manager. The new Project Manager is the central hub for application development and can be used to organize and manage project files. A project is a collection of files, data, documents, and FoxPro objects that is saved as a file with a .PJX extension.

Project Manager window

The Project Manager organizes items in an outline view that you can expand or collapse. A plus sign (+) appears next to a symbol if the project contains one or more items of that type. You can click the plus sign to expand the list. This allows users to access all files associated with the project very quickly without having to go to another area of Visual FoxPro 3.0. You can also open multiple projects, and drag and drop files between open projects.

You can dock the Project Manager window by dragging it to the top or the bottom of the screen. When it is docked, the Project Manager collapses to display only tabs, thus freeing the desktop for designing database applications.

The Database Designer displays all tables, views, and relationships contained in the database. It allows users to create database schemes graphically by adding tables, then associating those tables graphically by dragging and dropping fields.

The Visual FoxPro 3.0 Database Container file stores all the information about a database, including its tables, local views, remote views, and connections. When a user creates a connection to back-end data, the information is stored within the Database Container. This functionality provides easy access to Microsoft BackOffice (specifically Microsoft SQL Server) without leaving Visual FoxPro.

When relationships are set within the Database Container, they are persistent throughout the entire application. For example, when you use multiple tables for forms and reports, FoxPro creates relationships between the tables automatically, based on the relationships specified in the Database Designer, thus providing an efficient development environment.

Regardless of their complexity, nearly all database applications require the use of forms. In Visual FoxPro 3.0, the Form Designer has been improved to increase ease of use and productivity. For example, you can now align objects easily with the Layout toolbar and access an object's layout properties using the tabbed Properties window. You can bind objects and data easily with the graphical Data Environment Designer. You can create complex data management forms by dragging and dropping fields and controls on the form design surface.

The Form Designer is tightly integrated with the Visual FoxPro 3.0 object model. For example, you can save a group of objects as a class while you are designing a form. The Form Controls toolbar is context sensitive, so you can populate the toolbar visually with a specific user-defined class library. The improvements in the Form Designer are also included in the Class Designer, so users do not have to learn two different interfaces for building forms and classes.

Form Designer

With Visual FoxPro, you can create classes programmatically with the DEFINE CLASS command (as discussed above), or visually with the Class Designer. The Class Designer allows users to create their own properties and methods. When a property or method has been defined, it appears on the property sheet.

The classes created in the Class Designer can be based on FoxPro base classes or on custom classes defined by users. They fully support inheritance, subclassing, polymorphism, and encapsulation.

OLE support, too

Visual FoxPro 3.0 also supports OLE services, which are designed to help developers build custom applications more quickly. For building integrated solutions, for example, Visual FoxPro 3.0 includes OLE Automation, which enables it to programmatically control other business tools such as the Microsoft Office business productivity applications. (See "Using OLE Automation in Visual FoxPro" by Paul Bienick, Developer Network News, July/August 1995.)

Pricing

Visual FoxPro version 3.0 Professional Edition is now available, with an estimated retail price of US$499; an upgrade from previous versions costs an estimated US$299. The Standard Edition has an estimated retail price of US$199 (upgrades US$99). For more information, please call (800) 426-9400 from within the United States or Canada. For price and availability information in other countries, contact your local Microsoft subsidiary.You can also get more information on the World Wide Web at http://www.microsoft.com/foxpro.

Jon Sigler is the lead technical product manager for Microsoft Visual FoxPro. He is responsible for encouraging the product group to include the features and functionality users request.