design_pattern
basic principle
- SOLID >> S: single resposibility
O: open-closed: open for extension, closed for modification
simple shoud not go back to code/modify somthing haveing writtern adn tested L: liskov substitution
if interface is ok to type A, it should also is ok to its inherited type B I: interface segregation
D: dependency inversion
high level module should not depend on low level; absraction should not depend on detail
factory method pattern
- Delegation of object creation to factory method
- Extensibility by permitting arbitrary many factory methods
- Code reuse through runtime polymorphism
- Decouple initialization of factories from creating connections
1 | struct Connection { |
structural: composite
- array backed property
1
2
3
4
5class widget {
enum abilities {strenth, agi, teli, count};
std::array<int, count> properties;
};
NON-Virtual Interface pattern(NVI) -- Template Method Pattern
M&M rule
mutable and mutex(or atomic) should go together
-------------本文结束感谢您的阅读-------------