Further Isolation Techniques

The one problem with this approach is that you would have to physically replace the Stock class with a new one when you changed the implementation. You can get around this by using an intermediate model, which is configurable. As an exercise, here’s the Stock class rewritten to be configurable.

To begin, you need to define an interface that the new class will use to talk to all of the possible implementation-level classes. This interface, StockInterface, is shown in Listing 9.2.

Listing 9.2. StockInterface.java
 package stocktrack; import stocktrack.torque.StockPriceHistory; /** * <p>Title: Stock Tracking Application</p> * <p>Description: Example application from the book: * Struts - Rapid Working Knowledge</p> ...

Get Struts Kick Start now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.