Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Template method pattern
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Behavioral design pattern in object-oriented programming}} {{distinguish|Template processor}} {{more footnotes|date=March 2012}} In [[object-oriented programming]], the '''template method''' is one of the [[behavioral pattern|behavioral]] [[Software design pattern|design patterns]] identified by Gamma et al.<ref name=":0">{{cite book|title=Design Patterns|last1=Gamma|first1=Erich|last2=Helm|first2=Richard|last3=Johnson|first3=Ralph|last4=Vlissides|first4=John|publisher=Addison-Wesley|year=1994|isbn=0-201-63361-2|pages=[https://archive.org/details/designpatternsel00gamm/page/325 325β330]|chapter=Template Method|author-link1=Erich Gamma|author-link2=Richard Helm|author-link3=Ralph Johnson (computer scientist)|author-link4=John Vlissides|title-link=Design Patterns}}</ref> in the book ''[[Design Patterns]]''. The template method is a method in a superclass, usually an abstract superclass, and defines the skeleton of an operation in terms of a number of high-level steps. These steps are themselves implemented by additional ''helper methods'' in the same class as the ''template method''. The ''helper methods'' may be either ''[[abstract method]]s'', in which case subclasses are required to provide concrete implementations, or ''[[Hooking|hook methods]],'' which have empty bodies in the superclass. [[Subclass (computer science)|Subclass]]es can (but are not required to) customize the operation by [[Method overriding|overriding]] the hook methods. The intent of the template method is to define the overall structure of the operation, while allowing subclasses to refine, or redefine, certain steps.<ref name=":2">{{cite book|url=http://shop.oreilly.com/product/9780596007126.do|title=Head First Design Patterns|last2=Freeman|first2=Elisabeth|last3=Sierra|first3=Kathy|last4=Bates|first4=Bert|publisher=O'REILLY|year=2004|isbn=978-0-596-00712-6|editor-last=Hendrickson|editor-first=Mike|volume=1|pages=289, 311|format=paperback|editor-last2=Loukides|editor-first2=Mike|last1=Freeman|first1=Eric|access-date=2012-09-12}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)