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