Unforeseen Adaptation

Suppose that an existing application at Oozinoz issues warnings and prints out other messages to System.out. The commonly used expression System.out is an instance of PrintStream. Noting this and foreseeing that you might want to redirect the message output, the application's designers have built in a setOutput() method. It would be better if these designers had defined the interface they required for displaying messages. That would have let you provide an implementation for just the PrintStream methods that the application uses. But at least the setOutput() method lets you supply a different instance of PrintStream as the message channel.

Suppose that you want to redirect the messages to appear in a JText-Area object. Inspecting ...

Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.