Information Technology Reference
In-Depth Information
public Account CreditCardInfo { get ; set ; }
}
The customer class does not contain the kind of API that should be called
remotely. Calling a remote customer results in excessive traffic between
the client and the server:
// create customer on the server.
Customer c = Server .NewCustomer();
// round trip to set the name.
c.Name = dlg.Name;
// round trip to set the addr.
c.ShippingAddr = dlg.ShippingAddr;
// round trip to set the cc card.
c.CreditCardInfo = dlg.CreditCardInfo;
Instead, you would create a local Customer object and transfer the
Customer to the server after all the fields have been set:
// create customer on the client.
Customer c2 = new Customer();
// Set local copy
c2.Name = dlg.Name;
// set the local addr.
c2.ShippingAddr = dlg.ShippingAddr;
// set the local cc card.
c2.CreditCardInfo = dlg.CreditCardInfo;
// send the finished object to the server. (one trip)
Server .AddCustomer(c2);
The customer example illustrates an obvious and simple example: Trans-
fer entire objects back and forth between client and server. But to write
efficient programs, you need to extend that simple example to include the
right set of related objects. Making remote invocations to set a single prop-
erty of an object is too small of a granularity. But one customer might not
be the right granularity for transactions between the client and server,
either.
To e x t e n d t h i s e x a m p l e i n t o t h e r e a l - w o r l d d e s i g n i s s u e s y o u ' l l e n c o u n t e r
in your programs, we'll make a few assumptions about the system. This
software system supports a major online vendor with more than 1 million
customers. Imagine that it is a major catalog ordering house and that each
customer has, on average, 15 orders in the last year. Each telephone oper-
Search WWH ::




Custom Search