Seeing Partial Population in Practice


Partial population is most evident in the database world. With databases, there is typically no requirement to retrieve an entire row of data or update an entire row of data at a single time. In fact, SQL and other query language derivations allow you to partially populate data or retrieve portions of a row in a database without having to deal with the other pieces of data.

Table 17-1 shows one of the database tables that lies underneath the RoastedCoffeeBeansImpl class and that Java Data Objects (JDO) use for persistence. This table tracks the information about the individual coffee beans that you roast and sell.

Table 17-1: Roasted Coffee Bean Database Table

LIDOID

DESCRIPTION

NAME

SKU

WHOLESALE PRICE

RETAIL PRICE

POUNDS

TYPE

6

Bold and Rich

French

1044147687015

7.00

9.95

1

7

Smooth

P.T. Breakfast

1044147687016

7.00

9.95

1

Using SQL, it is easy to get a summary of the roasted coffee beans that includes the name, description, and retail price:

 select Name, Description, RetailPrice from wsbook.csbwe_roastedcoffeebeansimpl; 

From this query, the database returns the data in Table 17-2.

Table 17-2: Query Result Table

NAME

DESCRIPTION

RETAIL PRICE

French

Bold and Rich

9.95

P.T. Breakfast

Smooth

9.95

The flexibility inherent in SQL and database manipulation does not typically translate to object-oriented Application Programming Interfaces (APIs). Object orientation puts type safety and structured contracts above the ability to manipulate the underlying data at will. Part of the reason for the structure is the desire to couple data and behavior in a single class. Once you protect the data from the user and overlay the data with behavior, it becomes incrementally more difficult to allow a client to freely manipulate data.

On the other hand, this book has encouraged decoupling data and behavior, leading to the promotion of the four base patterns (the Business Object, Business Object Collection, Business Process, and Asynchronous Business Process patterns). Using structured data allows you to use more flexible data manipulation techniques. Using a partial population technique in the P.T. Monday Coffee Company application will help set up your customers for success by allowing them to select and change only the data they need without the weight of the extraneous data. This pattern gives more flexibility to the Web Service user and does not force you to create data transfer objects for every variant of data that you think a customer may want.




Web Service Patterns
Web Services Patterns: Java Edition
ISBN: 1590590848
EAN: 2147483647
Year: 2003
Pages: 190

Similar book on Amazon

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