Method (computer Programming) - Hook Methods

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:

    A hook shot kisses the rim and
    hangs there, helplessly, but doesn’t drop

    and for once our gangly starting center
    boxes out his man and times his jump

    perfectly, gathering the orange leather
    from the air like a cherished possession
    Edward Hirsch (b. 1950)

    The greatest part of our faults are more excusable than the methods that are commonly taken to conceal them.
    François, Duc De La Rochefoucauld (1613–1680)