Utilization

[Previous] [Next]

Use the Repository design pattern for the following purposes:

  • To save the state of an object at a specific moment in time For example, whenever the state (the number of shares in the stocks held) of a StockPortfolio object has changed because of interface method invocations (StockPortfolio.executeOrders, StockPortfolio.cancelOrders, or StockPortfolio.replaceOrders), its state should be persisted to a repository.
  • To reestablish the state of an object from a specific moment in time For example, when a user logs off the stock portfolio management system, the StockPortfolio object that represents the user's portfolio is destroyed; however, the state is preserved in a repository. When the user decides to log on to the system again, a new StockPortfolio object must be created and the state reestablished, facilitated through a repository.
  • To abstract the varying implementations required to store and retrieve the state of an object from a specific data store For example, let's assume there are numerous classes in a stock portfolio management system that could individually define data manipulation routines implemented in a specific technology, such as Microsoft Data Access Objects (DAO). First, it would become increasingly difficult to maintain the various data manipulation routines. Second, if you decide to replace DAO with ADO (ActiveX Data Objects) technology, you would be required to change code in every class that references DAO. To avoid this predicament, the data manipulation routines for storing and retrieving data can be centralized and encapsulated in a repository class.


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