Hook Methods
Hook methods are defined in abstract classes and called from a template method. Hooks are used as placeholders that can be supplied by the component's client in a concrete derived class. Here is a Java example:
/** */ public abstract class Beverage implements Beveragelike { /** * Adds condiments to the beverage */ public abstract void addCondiments; /** * Hook method that determines whether the customer wants condiments * or not. Can be overridden. * @return true, if the customer wants condiments, and false otherwise. */ public boolean customerWantsCondiments { return true; } /** * Prepares the beverage according to this recipe. */ public final void prepareRecipe { // … if (customerWantsCondiments) { addCondiments; } } }Read more about this topic: Method (computer Programming)
Famous quotes containing the words hook and/or methods:
“And yetit is not beauty that inspires the deepest passion. Beauty without grace is the hook without the bait. Beauty, without expression, tires.”
—Ralph Waldo Emerson (18031882)
“With a generous endowment of motherhood provided by legislation, with all laws against voluntary motherhood and education in its methods repealed, with the feminist ideal of education accepted in home and school, and with all special barriers removed in every field of human activity, there is no reason why woman should not become almost a human thing. It will be time enough then to consider whether she has a soul.”
—Crystal Eastman (18811928)