Robert Coleridge
Microsoft Developer Network
Updated: September 1999
Summary: Outlines the Duwamish Books sample. (4 printed pages) Includes:
Duwamish Books is a sample sales and inventory system. As the fictional Duwamish Books grows from a single store to a Web-based operation, MSDN migrates the sample from a desktop application (classical architecture) to a basic client/server environment (three-tier) and, finally, to a Web-based retail store (distributed three-tier, or n-tier).
The transition is presented in four phases. We give you great reusable code, documentation of the different applications, and discussions of the issues and strategies involved with the design and migration. Through this series we highlight such issues as middle-tier component design, migrating divergent user interfaces to consistent designs, and distributed database access. As such, our goal is not to provide a full-featured retail system, but a subset of a possible system that can be used as a learning tool (or, for the more motivated, as the basis of a development project). We have concentrated on the technologies and features that would best demonstrate the critical issues involved with this type of migration.
Phases 1 and 2 are implemented using Microsoft® Visual Basic® version 5.0 with a Microsoft Access database.
Phases 3 through 4 are implemented using Visual Basic version 6.0.
Phases 3 and 4 use a Microsoft SQL Server™ database so that the applications can take advantage of its advanced feature set and scalability.
The Duwamish Books story is a simple version of business growth. Initially, a single store comprised the whole business, and a simple desktop application fit all their business needs (Phase 1). However, some success allowed the owners to expand to additional outlets, requiring a centralized database that could be accessed by each store (Phase 2). As this success continued and Duwamish moved into different states and countries, the system had to account for differing business rules, such as changes in tax rates from store to store, requiring further modifications (Phase 3).
Because our Duwamish Books is run by forward-looking and savvy businesspeople, they decided to move their store online. The move to the Web involved not only handling much larger amounts of incoming data, but also a rethinking of the user interfaces (Phase 4).
The Duwamish Books migration, from a simple architecture to a Web-based n-tier architecture, is built around the same basic functionality.
While not much more is built into Phase 1, subsequent phases see enhancements to this functionality.
Key to this sample is an understanding of the various layers employed by most user interface–based, data processing applications:
With this sample, we demonstrate not only how to write a good desktop (Phase 1) sample, but also how to migrate such an application to other equally valid business scenarios. Phase 2 expands to a two-tier model and Phase 3 to a three-tier application model. Phase 4 (the Web) highlights the issues involved in designing an n-tier distributed application.
Figure 1 illustrates these architectural models.
Figure 1. The migration path
In the classic model, note how all layers are held within the application itself. This architecture would be very awkward to maintain in a large-scale environment unless extreme care was taken to fully encapsulate or modularize the code. Because Phase 1 of the Duwamish Books sample focuses on a small retail operation, this type of design is perfectly acceptable. It's easy to develop and, in the limited environment of a single retail outlet, easy to maintain.
In Phase 1 we deliver the basic functionality and documentation of the code and design issues.
Phase 2 moves to a two-tier design, as we break out the data access code into its own layer. By breaking out this layer, we make multiple-user access to the data much easier to work with. The developer does not have to worry about record locking, or shared data, because all data access is encapsulated and controlled within the new tier.
The business rules layer contains not only rules that determine what to do with data, but also how and when to do it. For an application to become scalable, it is often necessary to split the business rules layer into two separate layers: the client-side business logic, which we call workflow, and the server-side business logic. Although we describe these layers as client and server–side, the actual physical implementations can vary. Generally, workflow rules govern user input and other processes on the client, while business logic controls the manipulation and flow of data on the server.
Phase 3 of the Duwamish Books sample breaks out the business logic into a COM component to create a logical three-tier application. Our second step in creating a three-tier application is to provide a physical implementation of the architecture. To distribute the application across a number of computers, we implement Microsoft Transaction Server in Phase 3.5. The application becomes easier to maintain and distribute, as a change to the business rules affects a smaller component, not the entire application. This involves some fairly lengthy analysis because the business rules in Phase 1 were deliberately not encapsulated.
Phase 4 of the Duwamish Books sample is the culmination of the migration from a desktop model to a distributed n-tier model implemented as a Web application. In Phase 4, we offer three client types aimed at different browser types. We also break out the workflow logic from the client application. This logic is now implemented through a combination of ASP script, some client-side processing (depending on the client type), and a COM component. The Workflow component converts ADO Recordsets it receives from the Business Logic Layer component into XML data, which is, in turn, converted into HTML for presentation.
Phase 4 documents the benefits, architecture, and implementation issues relating to the migration of a three-tier application to a Web-based application.
Duwamish Books may be a fictitious company but the design, development, and deployment issues raised throughout the four phases of the project are not. We will hopefully expose and clarify these issues for you.
Feel free to send us e-mail with your questions, comments, or feedback to duwamish@microsoft.com.