Component Design in Island Hopper News

Both the Win32 client, written in Visual Basic, and the Web client access the same set of Component Object Model (COM) components running in Microsoft Transaction Server (MTS) on Windows NT. The Web client calls the objects from scripts running on Active Server Pages (ASP) pages. The Win32 client accesses additional components related to tracking and billing customers. The Win32 client uses distributed COM (DCOM), and the Web application uses ASP files (accessed via HTTP), to communicate with the business-services components. All changes—including updates to ads, new ads, and billing—are securely transacted to a SQL Server database.

The following diagram illustrates the architecture of Island Hopper News.

The application uses components built as COM dynamic-link libraries (DLLs) that run in the MTS environment. Instances of these components enforce the application's business rules. For example, the classified ad component has methods to place, update, and delete ads, as well as to retrieve them by customer name or by category.

To run in the MTS environment, components must be deployed as MTS packages using the MTS Explorer, a Microsoft Management Console (MMC) snap-in. This benefits application development in several ways:

The way you make decisions about which components to place in which packages can help you make your application more stable and secure.

One way you might decide to package components is to group together components that share expensive resources, such as Open Database Connectivity (ODBC) connections, in the same package. MTS has several resource management features that improve the scalability of your application. These features are managed separately for each MTS process. For example, with connection pooling, a pool of ODBC connections is shared by all components in a package.

Island Hopper News takes advantage of other MTS features designed to enhance scalability. For example, MTS provides a context object, which is created when an MTS component is instantiated. The context object enables the server to create objects only when they are needed, and to destroy them when they have done their work. Components use the context object methods, SetComplete and SetAbort, to indicate when their work is done. These methods also enforce transactional behavior on the part of objects that call them.

The Island Hopper News components, with one exception, do not maintain state; that is, objects are destroyed between method calls on an interface. For many tasks, this is a good design choice, but it is not the only one. A more sophisticated application might use more stateful components. For example, it might be wise for an object that passes complex database queries to persist; maintaining the object in memory might actually be less resource-intensive than re-creating it each time you need to query the database.