Recommended sites

Add to MyYahoo!
Subscribe in NewsGator Online
Add to Newsburst
Add to Google
Add to My AOL
Add to Pluck
Subscribe in FeedLounge
Add to Windows Live
Add to NetVibes
Subscribe in Rojo
Subscribe in Bloglines
Add to MyMSN
Add to Plusmo for your cellphone
Add to PageFlakes
Add to Technorati
Add to BlinkBits
Template method Print E-mail
User Rating: / 1
PoorBest 
Thursday, 27 January 2005 20:00
Defines the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses refine certain steps of an algorithm without changing the algorithm's structure.


Source Code


/**  
* This class defines abstract primitive operations that concrete
* subclasses define to implement steps of an algorithm. Implements a template
* method defining the skeleton of an algorithm.
*
* @role __TemplateContext */ public abstract class Context { /**
* Primitive operation.
*/ public abstract void doPrimitiveOperation(); /**
* Defines the skeleton of an algorithm. Calls primitive operations as well
* as operations defined in AbstractClass or those in other objects.
*/ public void templateMethod() { // put your code here doPrimitiveOperation(); // put your code here } } /**
* Implements the primitive operations to carry out subclass-specific steps of
* the algorithm.
*/ public class ConcreteClass extends Context { /**
@see patterns.gof.templatemethod.Context#doPrimitiveOperation()
*/ public void doPrimitiveOperation() { // provide implementation here } }
Template 
Comments
Add New Search RSS
Write comment
Name:
Email:
 
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
:):grin;)8):p:roll:eek:upset:zzz:sigh:?:cry
:(:x
Please input the anti-spam code that you can read in the image.

3.20 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated ( Friday, 17 June 2005 23:42 )
 


Another articles:


Content View Hits : 2512731

Enter Amount: