Microsoft Visual Basic Design Patterns (Microsoft Professional Series)

[Previous] [Next]

I have enhanced the off-line banking system sample application (BSTAM Banker) from the Object By Value design pattern (Chapter 6) to include the Repository design pattern. To summarize, the BSTAM Banker allows bank customers to perform an extensive list of banking services (such as depositing and withdrawing funds and checking the balance) against their accounts off-line. The benefits are mainly optimal system performance without the loss of functionality. Why shouldn't you have your cake and eat it too? In the Chapter 6 sample, customer savings accounts are maintained in a Scripting.Dictionary object by the BankSvr.Teller object. This requires the Teller object to have intimate knowledge about how to manipulate the Dictionary object. What if later you decide to store the accounts in a Sybase database? The Teller object's implementation would have to be rewritten using an appropriate Sybase database API.

Let's say, for example, you decide to use ADO. Manipulating data using ADO is not even remotely similar to using a Dictionary object. Sounds like a big change? Well it is. To remove from the business object layer the responsibility, complexity, and limitations associated with data manipulation in a specific type of data store, in this example I've replaced the Dictionary object with an implementation of the Repository design pattern. Since the SavingsAccount objects are persistable, half the design pattern is already implemented. All that is required is a Repository object. Hence this sample is an ideal fit. Finally, a new feature not found in the BSTAM Banker example in Chapter 6 has been added to allow a customer to update his or her account with the changes made off-line. Account updates are ultimately stored in the Repository referenced by the Teller object. Since BSTAM Banker is already explained in great detail in Chapter 6, here I'll concentrate solely on the Repository design pattern implementation. For a complete source code disclosure, refer to the companion CD.

The key participants of the sample that make up the Repository design pattern include the following:

Категории