We use cookies to improve your experience with our site.

挖掘设计模式应用场景和相关设计模式对:基于网络发帖的案例研究

Mining Design Pattern Use Scenarios and Related Design Pattern Pairs: A Case Study on Online Posts

  • 摘要: 1、研究背景(Context):
    在设计模式相关文档(如设计模式书)中,作者通常使用固定的模板对各个设计模式进行描述。这些模板通常包括多个属性(attributes),如设计模式的“目的”、“结构”和“示例代码”等。为了使设计模式文档能够对当前的开发者具有参考价值,这些属性的描述应当与最新的编程技术联系起来。例如,在经典设计模式书Gang-of-Four中,属性“已知应用”描述的是设计模式在实践中的具体应用场景,属性“相关模式”说明了该设计模式与哪些其它设计模式有关。因为该书出版时间较早,其内容很难对当前编程技术有所反映。但是,由于编程技术的多样性,人工对这些属性的内容进行及时有效地更新又存在困难。
    2、目的(Objective):
    本文旨在构建一种方法,能够在编程相关的网络发帖中挖掘设计模式应用场景和相关设计模式对,以对上述两个属性的内容进行有效地补充;同时,将该方法应用到Stack Overflow网站的帖子中,以进行案例研究。
    3、方法(Method):
    首先,识别出Stack Overflow上面的设计模式标签,并提取出包含这些标签的帖子;然后,利用主题建模技术发掘出各个设计模式对应的主题分布;最后,通过分析单个设计模式和共现设计模式对相应的主题,得到各个设计模式的应用场景和相关设计模式对。
    4、结果(Result&Findings):
    通过该案例研究,我们得到195个设计模式应用场景和70组相关设计模式对,总共涉及61个设计模式。这些结果能够很好地反映当前比较流行的软件框架,如Ruby on Rails、Spring和ORM,以及编程方向,如移动开发、机器学习和web服务等,因此对当前的开发者具有参考价值。
    5、结论(Conclusions):
    本文提出了一种对设计模式相关属性的内容进行挖掘和丰富的方法,并进行案例研究,从Stack Overflow网站的帖子中发现了195个设计模式应用场景和70组相关设计模式对。这些结果能够对设计模式相关文档进行补充,并且能够让开发者更好地了解在编程实践中设计模式如何使用以及设计模式间的关系。在今后的研究中,我们将把该方法应用于其它数据源,并尝试提升方法的自动化程度。

     

    Abstract: In common design pattern collections, e.g., design pattern books, design patterns are documented with templates that consist of multiple attributes, such as intent, structure, and sample code. To adapt to modern developers, the depictions of design patterns, especially some specific attributes, should advance with the current programming technologies, for example, “known uses”, which exemplifies the use scenarios of design patterns in practice, and “related patterns”, which describes the relatedness between a design pattern and the others within a context. However, it is not easy to update the contents of these attributes manually due to the diversity of the programming technologies. To address this problem, in this work, we conducted a case study to mine design pattern use scenarios and related design pattern pairs from Stack Overflow posts to enrich the two attributes. We first extracted the question posts relevant to each design pattern by identifying the design pattern tags. Then, the topics of the posts were discovered by applying topic modeling techniques. Finally, by analyzing the topics specified for each design pattern, we detected 195 design pattern use scenarios and 70 related design pattern pairs, involving 61 design patterns totally. These findings are associated with a variety of popular software frameworks and programming techniques. They could complement the existing design pattern collections and help developers better acknowledge the usage and relatedness of design patterns in today's programming practice.

     

/

返回文章
返回