• Home
  • Forum
  • Terms and Privacy
17ebook! free ebooks! free download!
$3500 in cash could be yours! Enter today


Search here...
     

Head First Design study notes-Template Method Pattern

Posted by admin 17 February, 2011

Complete a short survey and get free Brand Name samples from QualityHealth.com!Head First Design study notes Template Method Pattern

One to ‘style’ of ‘style’
Template method (Template Method), the name contains a double meaning:
1. What do the model (template): It defines an algorithm skeleton
2. How to do: Method, in a method
In short, the Template Method Pattern defined algorithm framework is key to the method. The general structure is as follows:

Of course, not all steps are abstract, in the superclass where some of the steps can also provide a default implementation.
There is also a template method in the concept hook: some steps are not Required, subclasses can control whether or not the steps.
protected bool NeedStep1 = true;
…
public void TemplateMethod ()
{
if (NeedStep1)
{
Step1 ();
}
Step2 ();
}
…
Second, the ‘style’ that use:
Workflow process involving, in the submission of the various processes from one step to the next step may occur when the following situations:
1. Remove the draft data
2. Save the business data
3. To promote the process
4. Prompts Results
This is the template pattern of a typical application scenarios. First, the definition of operational procedures: public abstract class ProcessBase
{
protected bool NeedPrompt = false;
public void Submit ()
{
/ / 1. Remove the draft data
DeleteDraft ();
/ / 2. Save the business data
SaveBizData ();
/ / 3. To promote the process
SubmitProcess ();
/ / 4. Prompts Results
if (NeedPrompt)
{
Prompt ();
}
}

public void DeleteDraft ()
{
Console.WriteLine (“Deleting Draft …”);
}
public abstract void SaveBizData ();

public abstract void SubmitProcess ();

public void Prompt ()
{
Console.WriteLine (“Success!”);
}
}
With such a base class that contains the template method, the implementation process of the submission of each action is simple:
public class Process1: ProcessBase
{
public Process1 (): base ()
{
NeedPrompt = true;
}
public override void SaveBizData ()
{
Console.WriteLine (“Saving Biz data …”);
}

public override void SubmitProcess ()
{
Console.WriteLine (“Submitting process …”);
}
}
Third, watching the film
More than a little learning experience for individuals and records, please advise.

Categories : book review Tags :

Comments

No comments yet.


Sorry, the comment form is closed at this time.

Subscribe via Email


Windows Touch Technics and Technology tablet Solution Manual Smart Security/Hacking Science Related Science/Engineering samsung Review Programming Phones phone Nokia Newspapers netbooks Netbook Mobile Medical/Medicine Lumia Laptops Laptop IT Certification Iphone Hobbies Health Graphics and Design Game For Women For Men features Ericsson Encyclopedias Economics and Finances Economics/Business deals DB Consumer Electronics Computer Related Computer Comics Apple android about
  • Categories

    • book review
    • Ebook Download
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
  • Archives

    • June 2013
    • May 2013
    • April 2013
    • March 2013
    • February 2013
    • January 2013
    • December 2012
    • November 2012
    • October 2012
    • September 2012
    • August 2012
    • July 2012
    • June 2012
    • May 2012
    • April 2012
    • March 2012
    • February 2012
    • January 2012
    • December 2011
    • November 2011
    • October 2011
    • September 2011
    • August 2011
    • July 2011
    • June 2011
    • May 2011
    • April 2011
    • March 2011
    • February 2011
    • January 2011
    • December 2010
    • November 2010
    • October 2010
    • September 2010
    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
  • Recent posts

    • Complete Solution for Windows BSOD or Blue Screen of Death
    • HTC Sensation 4G – Great Sensation releasing in Mid of May
    • Knowing Nokia Lumia 800 Deals More Closely
    • Windows Mobile Development Shift Focus Back to Corporate
    • Microsoft’s Windows Phone Needs to Attack the Midmarket
    • Upgrade for you to House windows 7 and Keep Windows XP Apps
    • The iPAQ Voice Messenger provides unrivalled styling and a QWERTY keyboard
    • Get The Latest Mobile Phones at Economical Price
    • Sony Ericsson Xperia Neo V a Latest Smartphone
    • Fax Messaging in Windows 7 – The How to And Why

Copyright © 2013 17ebook! free ebooks! free download! All right reserved

  • Home
  • Forum
  • Terms and Privacy