Template method Pattern of design pattern learning notes

Source: Internet
Author: User
The template method pattern defines the skeleton of an algorithm in one method, and some steps are deferred to subclasses.    The template method allows subclasses to redefine some of the steps in the algorithm without changing the structure of the algorithm. A template is a method. This method defines the algorithm as a set of steps, in which any step can be abstract and the subclass is responsible for implementing it.    This ensures that the algorithm structure remains the same, while the subclass provides partial implementations. Note: 1, in order to prevent the subclass change the template method in the algorithm, the template method can be declared final, 2, the policy mode and template method pattern are encapsulated algorithm, a use of combination, one with inheritance; 3, the factory method is a special version of the template method;

Template method Pattern of design pattern learning notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.