Level C — Business and Data Access Components

   

The Island Hopper News sample Level C business and data access components are COM components that encapsulate processing. Using components in this way helps create a modular application, one that you can adapt as needed. It is much easier to replace one or two components than to rewrite an entire application.

Why Two Levels?

You might wonder why the Island Hopper News sample separates the business components from the data access components. Why the level of abstraction? Here's why: Separating the data access components makes it possible to use specialized querying rules that are not strictly business rules and that are not appropriate for building into the storage engines, particularly when data is decentralized, as is typical in many companies. For instance, one query may want all customers, but "James Smith" at a specific address and "Jim Smith" at the same address should be recognized as the same person. This is perhaps a contrived example, but the point is that data access code often becomes extremely complex and yet really does not belong with the business logic nor stored with the storage engine.

Component Summary — Level C

Level C contains the components described in the following table. Most of these are written in Visual Basic.

Level C Business Components

Name Description

bus_AdC

Manages classified ads. Creates instances of db_AdC, db_CategoryC, db_ProductC, where necessary to carry out database functions. Reused from Level A with added functionality.

bus_CustomerC

Manages customer information.

bus_InvoiceC

Manages invoices. Written using Visual C++.

bus_PaymentC

Manages customer payments.

Level C Data Access Components

Name Description

db_AdC

Sends data to and retrieves data from the Advertisements table in the Classifieds database.

db_CategoryC

Sends data to and retrieves data from the Categories table in the Classifieds database.

db_CustomerC

Sends data to and retrieves data from the Customers table in the Classifieds database.

db_CustomerPasswordC

Sends data to and retrieves data from the CustomerPasswords table in the Classifieds database.

db_InvoiceC

Sends data to and retrieves data from the Invoices and InvoiceDetails table in the Classifieds database.

db_PaymentC

Sends data to and retrieves data from the Payments table in the Classifieds database. Written using Visual C++.

db_ProductC

Sends data to and retrieves data from the Products table in the Classifieds database.

util_TakeANumber

Utility component that assigns unique IDs to customers, invoices, and ads.

util_WordCount

Utility component that counts words in ads to calculate ad price. Written using Visual C++.