随笔分类 -  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 阅读全文
posted @ 2011-05-20 11:46 sun_kang 阅读(613) 评论(0) 推荐(0)
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 阅读全文
posted @ 2006-08-15 16:03 sun_kang 阅读(260) 评论(0) 推荐(0)