FACTOID # 174: One in three Italian babies is born by caesarean section.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

FACTS & STATISTICS    Simple view

  1. Select countries to view: (hold down Control key and click to select several)

     

     

    Compare:

     

     

  1. Select fact or statistic: (* = graphable)

     

     

     

  2. (OPTIONAL) Compare to statistic: (both need to be graphable)

     

     

     

  3. View result as:

     

       
(OR) SEARCH ALL encyclopedia, stats & forums:   

Encyclopedia > Template method pattern
Template method: UML class diagram.
Template method: UML class diagram.

In software engineering, the template method pattern is a design pattern. Image File history File links Template_Method_UML.svg Oggetto Licensing File links The following pages link to this file: Template method pattern ... Image File history File links Template_Method_UML.svg Oggetto Licensing File links The following pages link to this file: Template method pattern ... The Unified Modeling Language (UML) is a non-proprietary, object modeling and specification language used in software engineering. ... Hierarchy of UML 2. ... Software engineering (SE) is the practice of creating and maintaining software applications by applying technologies and practices from engineering, computer science, project management, application domains and other fields. ... In software engineering, design patterns are standard solutions to common problems in software design. ...


A template method defines the skeleton of an algorithm in terms of abstract operations which subclasses override to provide concrete behavior. Flowcharts are often used to represent algorithms. ...


First a class is created that provides the basic steps of an algorithm by using abstract methods. Later on, subclasses change the abstract methods to implement real actions. Thus the general algorithm is saved in one place but the concrete steps may be changed by the subclasses.


Example in Java

 /** * An abstract class that is common to several games in * which players play against the others, but only one is * playing at a given time. */ abstract class Game{ private int playersCount; abstract void initializeGame(); abstract void makePlay(int player); abstract boolean endOfGame(); abstract void printWinner(); /* A template method : */ final void playOneGame(int playersCount){ this.playersCount = playersCount; initializeGame(); int j = 0; while( ! endOfGame() ){ makePlay( j ); j = (j + 1) % playersCount; } printWinner(); } } 

Now we can extend this class in order to implement existing games:

 class Monopoly extends Game{ /* Implementation of necessary concrete methods */ void initializeGame(){ // ... } void makePlay(int player){ // ... } boolean endOfGame(){ // ... } void printWinner(){ // ... } /* Specific declarations for the Monopoly game. */ // ... } 
 class Chess extends Game{ /* Implementation of necessary concrete methods */ void initializeGame(){ // ... } void makePlay(int player){ // ... } boolean endOfGame(){ // ... } void printWinner(){ // ... } /* Specific declarations for the Chess game. */ // ... } 

Monopoly is one of the best-selling commercial board games in the world. ... Monopoly is one of the best-selling commercial board games in the world. ... Chess is an abstract strategy board game for two players. ... Chess is an abstract strategy board game for two players. ...

External links

  • Template design pattern in C# and VB.NET

  Results from FactBites:
 
Template method pattern - Wikipedia, the free encyclopedia (260 words)
In software engineering, the template method pattern is a design pattern.
A template method defines the skeleton of an algorithm in terms of abstract operations which subclasses override to provide concrete behavior.
First a class is created that provides the basic steps of an algorithm by using abstract methods.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.