面向可维护性的软件构建方法

模块化设计与实现——低耦合、高内聚
OO design principles – SOLID – GRASP
面向对象设计模式-工厂方法模式,构建器模式-桥接模式,代理模式-记忆模式,状态模式
基于状态的构造(基于自动编程)
表驱动构造
基于语法的构造
Maintainability—“The ease with which a software system or component can be modified to correct faults, improve performance, or other attributes, or adapt to a changed environment”. 易于纠正错 误和提升性能
Extensibility — Software design/implementation takes future growth into consideration and is seen as a systemic measure of the ability to extend a system and the level of effort required to implement the extension. 易于增加功能
Flexibility —The ability of software to change easily in response to user requirements, external technical and social environments, etc. 易 于改变
Adaptability— The ability of an interactive system (adaptive system) that can adapt its behavior to individual users based on informationacquired about its user(s) and its environment. 适应用户 个性化需求
Manageability—How efficiently and easily a software system can be monitored and maintained to keep the system performing, secure, and running smoothly.
Supportability—How effectivelya software can be kept running after deployment, based on resources that include quality documentation, diagnostic information, and knowledgeable and available technical staff. 发布后,软件受支持的程度
继承深度——表示扩展到类层次结构根的类定义的数量。层次结构越深,就越难理解在哪里定义或/和重新定义了特定的方法和字段。
类耦合——通过参数、局部变量、返回类型、方法调用、泛型或模板实例化、基类、接口实现、在外部类型上定义的字段和属性修饰来度量对惟一类的耦合。好的软件设计要求类型和方法应该具有高内聚性和低耦合性
单元测试覆盖率——指示自动化单元测试覆盖代码基的哪一部分
将程序的功能分散到独立可交互的模块中
模块化是高层的功能分解技术 ,在结构化编程中是如何根据控制流分解代码 ,在OOP中是指对象中数据的使用方式
Five Criteria for Evaluating Modularity
▪ Decomposability (可分解性) – Are larger components decomposed into smaller components?
▪ Composability (可组合性) – Are larger components composed from smaller components?
▪ Understandability (可理解性) – Are components separately understandable?
▪ Continuity (可持续性) – Do small changes to the specification affect a localized and limited number of components? 对规格说明的的改动,其影响是否是局部和有限的
▪ Protection (保护性) – Are the effects of run-time abnormalities confined to a small number of related components?
Five Rules of Modularity Design
▪ Direct Mapping (直接映射)
▪ Few Interfaces (尽可能少的接口)
▪ Small Interfaces (尽可能小的接口)
▪ Explicit Interfaces (显式接口)
▪ Information Hiding (信息隐藏)
(直接映射:模块的结 构与现实世界中问题领域的结构保持一致)
耦合是模块之间依赖关系的度量。如果一个模块中的更改可能需要另一个模块中的更改,则两个模块之间存在依赖关系。
内聚性是一个度量模块的功能或职责之间关系有多紧密的度量。
如果模块的所有元素都朝着同一个目标工作,那么模块就具有高内聚性。
SOLID
▪ (SRP) The Single Responsibility Principle 单一责任原则
▪ (OCP) The Open-Closed Principle 开放封闭原则
▪ (LSP) The Liskov Substitution Principle Liskov替换原则
▪ (ISP) The Interface Segregation Principle 接口隔离原则
▪ (DIP) The Dependency Inversion Principle 依赖转置原则
OO设计的两大武器
▪ 抽象(abstraction):模块之间通过抽象隔离开来,将稳定部分和容易 变化部分分开
▪ 分离(Separation): Keep It Simple, Stupid (KISS)
OO设计原则:掌握

**

可维护性的设计模式

**
创建模式
工厂方法模式在没有指定要创建的确切类的情况下创建对象
抽象工厂模式将具有共同主题的对象工厂分组
Builder模式通过分离构造和表示来构造复杂的对象。
结构模式
桥接将抽象与其实现解耦,这样两者就可以独立变化。
Proxy为另一个对象提供了一个占位符,用于控制访问、降低成本和降低复杂性。
Composite将0个或多个相似的对象组合在一起,这样就可以将它们作为一个对象进行操作。
行为模式
Observer是一个发布/订阅模式,允许多个观察者对象查看事件。
中介体允许类之间的松散耦合,因为它是唯一一个对类的方法有详细知识的类。访问者通过将方法的层次结构移动到一个对象中,将算法从对象结构中分离出来。
职责链将命令委托给处理对象链。
命令创建封装操作和参数的对象

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值