Skip to Main Content
Prefactoring
book

Prefactoring

by Ken Pugh
September 2005
Intermediate to advanced content levelIntermediate to advanced
240 pages
6h 28m
English
O'Reilly Media, Inc.
Content preview from Prefactoring

12.3. Exports

The Rentals in Sam's system are kept in RentalCollection. The information in Rental objects is used to produce the MultipleRentalDTO shown in the previous section, as well as the late return reports. If Sam wants to analyze the rentals for sales purposes, either analysis code has to be added to the system or the data has to be exported to an analysis program, such as SAS.

In keeping with the "Do a Little Job Well and You May Be Called Upon Often" guidelines, you should prepare systems to export data to and import data from other systems, such as analysis or accounting packages. Data can be exported periodically (snapshot) in standard formats for use in other systems. The export format can be XML, comma-delimited files, or some custom format. Data could also be made available in real time, as in an online ordering system that queries an inventory system for current availability of an item and notifies the inventory system when the order is placed.

We can use existing facilities of the underlying database to perform an export. Alternatively, we can create our own export methods. To demonstrate the alternative, for Sam's system we use export methods. There are two approaches to designing the export methods. We can use the existing methods in a class such as RentalCollection to retrieve a single Rental or a group of Rentals. Then we can create an interface that exports these Rentals (see Example 12-3).

Example 12-3. Export interface with groups of Rentals
 interface ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Understanding Unittest.Mock

Understanding Unittest.Mock

Mario Corchero
Java™ Performance

Java™ Performance

Charlie Hunt, Binu John

Publisher Resources

ISBN: 0596008740Supplemental ContentCatalog PageErrata