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)

Other articles related to "hook methods, method, hooks, hook method":

Method (computer Science) - 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 ... condiments to the beverage */ public abstract void addCondiments /** * Hook method that determines whether the customer wants condiments * or not ...

Famous quotes containing the words methods and/or hook:

    How can you tell if you discipline effectively? Ask yourself if your disciplinary methods generally produce lasting results in a manner you find acceptable. Whether your philosophy is democratic or autocratic, whatever techniques you use—reasoning, a “star” chart, time-outs, or spanking—if it doesn’t work, it’s not effective.
    Stanley Turecki (20th century)

    And yet—it is not beauty that inspires the deepest passion. Beauty without grace is the hook without the bait. Beauty, without expression, tires.
    Ralph Waldo Emerson (1803–1882)