Chapter 11 -- Repository

[Previous] [Next]

Chapter 11

A repository is a place where you store stuff. In the context of design patterns, stuff is an object's state. When you switch from client/server to n-tier software development, it's evident that the applications you develop are no longer datacentric. Hence your system design and implementation are no longer constrained by how data needs to be manipulated; instead you think in terms of objects. To a certain extent, you produce software that mirrors the functional process of a business by defining classes that are named after industry-specific terminology. The classes would implement the functionality depicted in the business process. For example, if you were developing a financial equity trading system, you most likely would define a StockPortfolio class that implements methods for executing, canceling, and replacing orders. A benefit of object-oriented development is that it is self-describing. It allows the programmer to represent concepts in source code symbolically. People are able to associate symbols with what those symbols represent and the actions that surround them.

A stock portfolio is a collection of stocks owned by an individual (for example, Ethan Spencer) or an entity (for example, the New York City Fire Department Pension Fund). An order is an instruction to buy or sell stock at a specified price. The action of executing an order carries out that order, and the actions of canceling and replacing orders modify outstanding orders. Managing a stock portfolio by using a client application in the client/server development model would involve direct manipulation of the data stored in the database. A client in the n-tier model would only invoke methods on objects that represent the business process. This doesn't mean that databases have been discarded from the system. What actually has occurred is that the responsibility of maintaining the data has shifted from the client to the business objects.

In the typical object-oriented system, objects live in memory. Since memory is a finite and precious resource, objects generally have a life cycle. They are created when needed and destroyed when their services are no longer required, making room in memory for other objects. At some future time, when the object's services are in demand again, you might need to re-create the object in its prior state, as is the case in the financial trading system example. It's obvious that the state of a stock portfolio must be retained. The Repository design pattern facilitates a common means to retain the state of objects. This chapter will describe how to accomplish this in Microsoft Visual Basic.



Microsoft Visual Basic Design Patterns
Microsoft Visual Basic Design Patterns (Microsoft Professional Series)
ISBN: B00006L567
EAN: N/A
Year: 2000
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net