Template Method Hooks

A hook is a method call that a developer places in his or her code to give other developers a chance to insert code at a specific spot in a procedure. When you are adapting another developer's code and you need control at a point where you don't currently have it, you can request a hook. An obliging developer can add a method call at the point that you need it. The developer will also usually supply a stubbed-out version of the hook method so that other clients need not necessarily override the hook method.

Consider the Aster star press that discharges its chemical paste and flushes itself with water when shutting down. The press has to discharge this paste to keep it from drying and clogging the machine. At Oozinoz, you ...

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.