Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8203173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:27:36+00:00 2026-06-07T07:27:36+00:00

Well, I was going through this excellent article on MSDN about Base Class Usage

  • 0

Well, I was going through this excellent article on MSDN about “Base Class Usage“. While I understand the concept of base class and interfaces, I am unable to comprehend the usage of Template methods in the second paragraph of this article (“Protected Methods and Constructors“).

Could anyone help me to understand this concept with the help of a simple practical example? Perhaps, understanding the concept of Template Method is a good place to start.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:27:39+00:00Added an answer on June 7, 2026 at 7:27 am

    That is very old article in my opinion, don’t remember seeing naming with Impl.

    I think wikipedia has better description:
    The template method is used to:

    • let subclasses implement (through method overriding) behavior that can vary

    • avoid duplication in the code: the general workflow structure is implemented once in the abstract class’s algorithm, and necessary variations are implemented in each of the subclasses.

    • control at what point(s) subclassing is allowed. As opposed to a simple polymorphic override, where the base method would be entirely rewritten allowing radical change to the workflow, only the specific details of the workflow are allowed to change.

    The control structure (inversion of control) that is the result of the application of a template pattern is often referred to as the Hollywood Principle: “Don’t call us, we’ll call you.” Using this principle, the template method in a parent class controls the overall process by calling subclass methods as required.

    In simple words, you define skeleton in your base class, and derived classes implement differences between implementations.

    Let’s say we have information, that must be published to different channels.
    So we make base class Publisher, that has skeleton how to do that.
    We force to implement initialization, that every derive would set address where to publish.
    We make sending implementation, that fits most of the channels and if some channel uses ftp instead of http, we let to override sending.
    And logging to dababase what was done is the same for all channels, so we don’t let to override that.
    Only publishing is interesing to user of Publisher derrived class, so only that method is public.

    public abstract class Publisher 
    {
          private address;
          // if you wish to force implementation in derived class, make method abstract
          private abstract void Initialize();
          // if you wish optional implementation in derived class, make it virtual
          protected virtual void SendChangesToWeb() 
          {
             // ...
             webClient.Upload(address, data)
          }
    
          // if you wish that some step could not be changed from outside 
          private void LogSentChangesToDatabase() 
          {
             // ... save date time when was send and what was sent
          }
    
          // this sequence is the same for all derives, no point to duplicate 
          public void PublishUpdates() 
          {
               Initialize();
               SendChangesToWeb();
               LogSentChangesToDatabase();
          }
    }
    
    public class GooglePublisher : Publisher {
         private override Initialize() 
         {
             address = "http://www.google.com";
         }         
    }
    
    public class FtpPublisher : Publisher {
         private override Initialize() 
         {
             address = "ftp://test.com";
         }     
    
         protected override SendChangesToWeb() 
         {
            FtpClient.Upload(address, data)
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going through the w3cschools XSLT tutorial, and I am at this page: xsl-if
Well, I've been going through my personal hell these days I am having some
I was going through: C++ FAQs about inheritance and decided to implement it just
I was going through The Well Grounded Rubyist and got confused by the following
Well, I was going through an application where a find a variable named as
I was going through operator precedence section of php.net and came across this example
I have a while loop that is going through and displaying an RSS icon
I have a few questions about PHP memory usage. I'm going to run some
I'm in a basic Engineering class and we're going through binary conversions. I can
I'm starting to learn to use Inkscape, and I'm going through this tutorial on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.