Deep Dive Into Design Patterns

一、面向对象 程序设计 简介 对象之间的关系 依赖:对类 B 进行修改会影响到类 A 。 关联:对象 A 知道对象 B。类 A 依赖于类 B。 聚合:对象A知道对象B且由B构成。类A依赖于类B。 组合:对象 A 知道对象 B、由 B 构成而且管理着 B 的生命周 期。类 A 依赖于类 B。 实现: 类 A 定义的方法由接口 B 声明。 对象 A 可被视为对象 B。类 A 依赖于类 B。 继承: 类 A 继承类 B 的接口和实现, 但是可以对其进行扩 展。对象 A 可被视为对象 B。类 A 依赖于类 B。 二、设计模式简介 设计模式是针对软件设计中常见问题的工具箱, 其中的工具 就是各种经过实践验证的解决方案。 创建型模式提供创建对象的机制, 增加已有代码的灵活性和可复用性。 结构型模式介绍如何将对象和类组装成较大的结构, 并同时保持结构的灵活和高效。 行为模式负责对象间的高效沟通和职责委派。 三、软件设计原则 优秀设计的特征 代码复用 代码复用是减少开发成本时最常用的方式之一。 复用的三个层次: [Read More]

Refactor

Essentially, refactoring is improving the design of code after it’s been written. If you want to add a feature to a program, but find that the code isn’t easy to change due to a lack of good structure, refactor that program first so that it’s easier to add the feature, and then add the feature. It is the change in requirements that makes refactoring necessary. The refactoring technique is to modify the program at a tiny pace. [Read More]