Scenario

[Previous] [Next]

In the process of developing a workflow application, you might find that instead of passing pure data from one process to another, it would be more efficient and scalable to pass around objects by value. Objects contain data, and methods that perform intelligent operations on that data. Passing the entire object is more efficient than requiring each process in the workflow to reimplement the behavior required to update a given data structure.

A point of sale system is an ideal candidate for the Object By Value design pattern. An order could be an object that contains data for the item—description, quantity, and price—but it would also contain the methods for adding and removing items from the order, calculating the total order value, changing the billing information, and so forth. For example, if a customer uses Microsoft Internet Explorer to place an order on line using your e-commerce system, both an ActiveX DLL class library that defines an Order class and an OCX ActiveX control that defines an order form are downloaded to the customer's computer. An instance of the order form control is created and embedded in an HTML document that is loaded in the customer's Web browser. In addition, an Order object is created to receive data from the order form control when a customer fills out the form. When the customer submits the order, the Order object is passed by value to the sales management process, which can then pass it by value to various other processes (for instance, credit card validation, inventory management, or accounts receivable) as part of the order fulfillment process. The sales management process might do the initial dispatching of the Order object to other processes, but some of the processes could also perform a set of actions on the Order object and pass it by value to other processes (for example, from warehouse to shipping and handling).

Passing the Order object by value rather than by reference offers some significant benefits. As mentioned earlier, each process is able to take advantage of the functionality provided by the Order object. Operations in a workflow system tend to occur serially among several processes distributed across a network, so passing the Order object by value is ideal because each process can invoke operations on an Order object that resides locally within the process, thus avoiding a high performance cost. Another benefit worth noting is that each process in the workflow can persist the state of the Order object with respect to the changes made in that process. If process B is ready to send the Order object to process C but process C is unavailable, process B can persist its Order object and resubmit the Order object by value to process C at a later time. When objects are passed by value rather than by reference, managing an object's state at different stages of the workflow process becomes an elegant design solution.

Although passing an object by value is not a language feature readily available in Visual Basic, implementing the Object By Value design pattern described in this chapter will effectively allow you to accomplish the desired results for your workflow application.



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