10.5. Interface Splitting

 <  Day Day Up  >  

The actions in the RentalOperations class introduced in Chapter 8 are definitely separate from the actions for searching a catalog. The search operations go into their own class, CatalogOperations . The only overlap is that methods in CatalogOperations need to find out if a particular CDDisc is rented, by invoking is_cd_disc_rented( ) . That method is currently in RentalOperations .

Status operations do not affect a system's state. They are just reporting mechanisms for the state of an object. We split the current RentalOperations interface into two interfaces: RentalOperations and StatusOperations . The rental status operation ( is_cd_disc_rented( ) ) is placed in StatusOperations .

Now, CatalogOperations needs StatusOperations , but it does not need RentalOperations , as shown in Figure 10-2. Splitting the interfaces allows us to better control the access to each function ("If You Forget Security, You're Not Secure"). The program used by a customer to perform catalog searches involves CatalogOperations , which has access to StatusOperations but not to RentalOperations .

Figure 10-2. Split interfaces

SPLIT INTERFACES

Split a single interface into multiple interfaces if multiple clients use different portions of the interface . [*]


[*] A reviewer suggested that you could find more information on splitting interfaces in Large-Scale C++ Software Design by John Lakos (Addison-Wesley Professional, 1996).

 <  Day Day Up  >  


Prefactoring
Prefactoring: Extreme Abstraction, Extreme Separation, Extreme Readability
ISBN: 0596008740
EAN: 2147483647
Year: 2005
Pages: 175
Authors: Ken Pugh

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