本文是加拿大蒙特利尔大学(University of Montreal)Foutse Khomh和Yann-Gaël Guéhéneuc开展的一项经验性软件研究的成果,他们已在此基础上发表了相关论文。
为了让国内开发人员也能够了解这项研究并能够参与其中,我将几篇相关论文的核心部分翻译并整理为本文,以供参考!
很多人都宣称设计模式的使用会给一些软件质量属性带来正面的影响,将改善软件质量,特别是改善软件的扩展性(Expandability)、可重用性(Reusability)和易理解性(Understandability),,但是也有一些人持怀疑态度。为了回答设计模式能否改善软件质量这个问题,最直接的方法就是询问软件开发人员的意见,大家根据实际开发和使用经验如何来评价每一个设计模式,听听大家的声音。
为此,Foutse Khomh和Yann-Gaël Guéhéneuc选取了10个常用的软件质量属性,有些质量属性与设计相关、有些与实现相关、有些与运行相关,并为此设计了一个调查问卷,要求开发人员结合这些质量属性对GoF 23种模式进行一个主观的评价,评价分为A、B、C、D、E五个等级:
A表示某个模式对某个质量属性有很大的正影响,(Very positive)
B表示某个模式对某个质量属性有一定的正影响,(Positive)
C表示某个模式对某个质量属性没有影响;(Not significant)
D表示某个模式对某个质量属性有一定的负影响,(Negative)
E示某个模式对某个质量属性有很大的负影响。(Very negative)
还提供一个特殊选项F: "I don't know",无法判断。(Not applicable)
研究方法
(1) 模式选择
GoF 23种设计模式
(2) 软件质量属性选择
与设计(Design)相关的属性:扩展性(Expandability)、简洁性(Simplicity)、可重用性(Reusability)
与实现(Implementation)相关的属性:易学性(Learnability)、易理解性(Understandability)、模块性(Modularity)
与运行(Runtime)相关的属性:普遍性(Generality)、运行时模块性(Modularity at runtime)、可伸缩性(Scalability)、健壮性(Robustness)
质量属性描述:
扩展性:一个系统设计方案能够被扩展的程度。(Expandability: The degree to which the design of a system can be extended.)
简洁性:一个系统设计方案易于理解的程度。(Simplicity: The degree to which the design of a system can be understood easily.)
可重用性:一个设计片段能够在另一个设计方案中被重用的程度。(Reusability: The degree to which a piece of design can be reused in an other design.)
易学性:系统源代码易于学习的程度。(Learnability: The degree to which the code source of a system is easy to learn.)
易理解性:系统源代码易于理解的程度。(Understandability: The degree to which the code source can be understood easily.)
模块性:系统所实现的功能与其他功能之间保持独立的程度(静态耦合度)。(Modularity: The degree to which the implementation of the functions of a system are independent from one another.)
普遍性:系统在运行时能提供的功能范围(数量)的程度(多少)。(Generality: The degree to which a system provides a wide range of functions at runtime.)
运行时模块性:系统在运行时功能与功能之间保持独立的程度(动态耦合度)。(Modularity at runtime: The degree to which the functions of a system are independent from one another at runtime.)
可伸缩性:系统在运行时能够处理大规模数据和计算的程度。(Scalability: The degree to which the system can cope with large amount of data and computation at runtime.)
健壮性:系统在异常情况或环境下功能能够继续正常运行的程度。(Robustness: The degree to which a system continues to function properly under abnormal conditions or circumstances.)
(3) 调查问卷格式(Sample)
Quality Attributes 1 | Quality Attributes 2 | …… | |
Design Pattern 1 | A/B/C/D/E/F | A/B/C/D/E/F | |
Design Pattern 2 | A/B/C/D/E/F | A/B/C/D/E/F | |
…… |
数据收集与处理
将调查问卷发送给30位具有较为丰富的设计模式理论知识和使用经验的开发人员(2007年1月-5月),最后收集到有效答卷数20份(有效答卷率貌似不太高,呵呵!),其中全部填写完整的有18份,填写90%的有2份。
Positive = A and B
Neutral = C
Negative = D and E
将选A和B定为正影响(Positive, G),选C定为中立(Neutral, N),选D和E定为负影响(Negative, B),统计结果如下:
考虑到篇幅不宜太长,详细的结果分析请见下文: