Design Pattern series-template

Source: Internet
Author: User

I. Class Diagram

 

Ii. Intention

DefineAlgorithmAnd delay some steps to the subclass.Te m p l a t e m e t h o dThis allows subclass to redefine certain steps of an algorithm without changing the structure of an algorithm.

Iii. Applicability

A) Implement the unchanged part of an algorithm at one time and leave the variable behavior to the subclass for implementation.

B) The Public behaviors in each subclass should be extracted and centralized into a public parent class to avoidCodeDuplicate.

C) control subclass extension. The template method is called only at a specific point."H o k"Operation.

Iv. Instances

the most commonly used template mode is in Dao mode. We usually write a lot of Dao class, our approach is to Dao total methods in abstract to one abstractdao , the direct benefit is code saving. The code is not listed. If you do not know the code, you can learn it online Dao mode is also a common mode.

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.