2015-03-10--Template Method pattern, Dimitri Law

Source: Internet
Author: User

There is something this morning, come back to take a rest in the afternoon, and then begin to learn. Today is actually the STL vector, not simple to see Ah, with who do not, to own hands to practice a, but to the present has not been realized, tomorrow himself to do a vector bar, today is mainly to see the code of others, and analyzed a bit, In fact, sometimes the analysis and design of the link is more important than the actual writing code.

Later in the evening continue our design pattern, today is still looking less, looked at the template method pattern and Dimitri law. We get one by one, first say template method mode.



The template method pattern is to realize its advantage by moving the invariant behavior to the superclass and removing the duplicated code in the subclass.


In fact, this design pattern I was in the actual project is also used, knowledge at the time do not know their use, this summed up is like a method inside the general are the same, only a few different, we can make these pure virtual function or virtual function, subclass to inherit and implement.


And one is the Dimitri rule.


In the structure design of a class, each class mobilization should minimize the access rights of members.
The fundamental idea of the Dimitri Law is to lose the loose coupling between classes.
The weaker the coupling between classes, the more beneficial it is to reuse, and a class that is in a coupling is modified without affecting the related classes.

Dimitri Law, that is to say, we expose the interface not too much, to achieve loose coupling.


Today is here, I finished brushing my teeth, immediately to bed, and tomorrow to get up 6 o'clock Ah, early rest. Everyone, crossing, get some rest earlier.


2015-03-10--Template Method pattern, Dimitri Law

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.