随笔分类 - Design Pattern
设计模式 - 网摘
摘要:SOLID 软件设计原则InitialStands for (acronym)ConceptSSRPSingle responsibility principle The notion that an object should have only a single responsibility. OOCPOpen/closed principle The notion that “software entities … should be open for extension, but closed for modification”. LLSPLiskov substitution pri
阅读全文
Factory
摘要:来个绘图经典的例子吧。基类是Shape,子类是Circle,Triangle等等。肯定有人写过这样的代码:enum SHAPE_DEFINE{CIRCLE, TRIANGLE, RECTANGLE };someFunction(){ SHAPE_DEFINE shape_variable; ……Shape * shap; switch(shape_variable) { case CIRCLE: shape = new Circle; break; case TRIANGLE: shape = new Trigangle; break; ..... } //do something with
阅读全文
浙公网安备 33010602011771号