Journal of Shandong University(Engineering Science) ›› 2020, Vol. 50 ›› Issue (6): 48-58.doi: 10.6040/j.issn.1672-3961.0.2020.229

• Machine Learning & Data Mining • Previous Articles     Next Articles

Design pattern classification mining with feature metrics constraints

Zhuoyu XIAO1(),Pei HE2,Guo CHEN1,Yunbiao XU1,Jie GUO1   

  1. 1. School of Information Engineering, Hunan Industry Polytechnic, Changsha 410208, Hunan, China
    2. School of Computer Science and Cyber Engineering, Guangzhou University, Guangzhou 510006, Guangdong, China
  • Received:2020-06-07 Online:2020-12-20 Published:2020-12-15

Abstract:

To solve low accuracy for design pattern mining, a method for design pattern classification mining with feature metrics constraints was presented. 47 feature metrics information based on structural pattern, behavioral pattern and creative pattern was classified and summarized, and definition of design pattern were given, and features of design patterns were described, three benchmark systems and four well-known system experiments for design pattern mining were designed. Experimental results show that proposed method is effective, and the accuracy of the proposed method was 96.13%, 91.67%, 72.23% for Adapter pattern. Command pattern and Factory method pattern for three benchmark systems, and the accuracy of the proposed method is 84.3%, 81.26%, 73.17% for Adapter, Command and Factory Method of design pattern for four well-known systems, compared to well-known methods by experiment of design pattern mining, indicating the effectiveness of the proposed method.

Key words: design pattern, design pattern mining, metrics constraints, classification, feature description

CLC Number: 

  • TP311

Fig.1

Frame of design pattern classification mining with feature metrics constraints"

Table 1

Feature index"

特征指标编号 特征指标名称 特征指标描述
F1 GetAllInterface(Class1, Class2, …, Classi, …) 取得接口信息, 其中Classi中下标i表示参与者序号
F2 GetAllClass(Class1, Class2, …, Classi, …) 取得类信息, 其中Classi中的下标i表示参与者序号
F3 HasGeneralization(Class1, Class2) Class1和Class2之间有泛化(Generalization)关系
F4 HasAssociation(Class1, Class2) Class1和Class2之间有关联(Association)关系
F5 HasAggregation (Class1, Class2) Class1和Class2之间有聚合(Aggregation)关系
F6 HasDelegation(Class1, Methodi, Class2, Methodj) Class1的Methodi方法代理了Class2的方法Methodj, 其中下标ij表示参与者Class中方法的序号
F7 NoHasAssociation(Class1, Class 2) Class1和Class2之间没有Association关系
F8 NoHasAggregation(Class1, Class2) Class1和Class2之间没有Aggregation关系
F9 HasCommonOperation(Class1, Class2, Method) Class1和Class2之间具有相同的Method
F10 HasAnnotation(Classi, Interfacej, Methodk) 对Class、Interface和Method进行标识, 其中下标ijk依次表示类、接口和方法的序号
F11 HasParameter(Method, Parameteri) Method可以拥有多个参数Parameteri, 其中下标i表示参数序号
F12 HasReturnValue(Methodi, Valuej) Methodi可存在返回值Valuei, 其中下标i表示参与者Method中方法的序号, j表示返回值Value的序号
F13 HasSameSignature(Methodi, Methodj) Methodi和Methodj具有相同的方法签名, 其中下标ij表示方法的序号
F14 HasCommonChildClasses(Class1, Class2, …, Classi…) 基类拥有i个派生类Classi, 其中下标i表示派生类的序号
F47 HasType(Variablei, Typej) 变量Variable的类型为Type, 其中下标i表示变量的序号, j表示Java变量的类型, 如整型、浮点型、字符型、日期型等

Fig.2

Definition of design pattern Feature index"

Fig.3

Adapter pattern"

Table 2

Description of adapter pattern feature index"

序号 特征指标描述
1 HasClass(Client, Adaptee, Target, Adapter)
2 HasAssociation (Adaptee, Adapter)
3 HasDelegation (Adaptee, Specific_Request, Adapter, Request)
4 HasGeneralization(Target, Adapter)
5 HasNoCommonInterface (Adaptee, Specific_Request, Adapter, Request)
6 HasNoInheritance (Target, Adaptee)
7 HasNoInheritance (Adaptee, Adapter)
8 HasNoDirectAccess (Adaptee, Client)
9 HasOperation (Adaptee, Specific_Request)
10 IsConcrete(Specific_Request)
11 IsInterface(Target)

Fig.4

Command pattern"

Table 3

Description of command pattern feature index"

序号 特征指标描述
1 HasClasses(Client, Command, Invoker, Concrete_Command, Receiver) & & IsInterface(Command)
2 HasInheritance(Concrete_Command, Command)
3 HasAggregate (Command, Invoker)
4 HasDelegation(Concrete_Command, Execute, Receiver, Action)
5 HasAssociation(Concrete_Command, Receiver)
6 HasCommonOperation(Concrete_Command, Command, Execute)
7 HasAccess(Receiver, Client)
8 HasOperation (Concrete_Command, state)
9 HasOperation (Receiver, Action)

Fig.5

Factory method pattern"

Table 4

Description of factory method pattern feature index"

序号 特征指标描述
1 HasClasses (Concrete_Product, Product, Concrete_Creator, Creator) & & IsInterface(Concrete_Creator, Product)
2 HasInheritance(Concrete_Product, Product)
3 HasDependency (Concrete_Product, Factory_Method)
4 HasGeneralization (Concrete_Creator, Creator)
5 HasNoInheritance(FactoryMethod, Concrete_Product, Product)
6 HasCommonOperation (Concrete_Creator, Creator, FactoryMethod)
7 HasClass (Factory_Method)
8 IsAbstract(Factory_Method)
9 HasReturnValue (Factory_Method, Concrete_Product)
10 HasReturntype(Factory_Method, Product)

Table 5

Parameters of benchmark system"

基准系统名称 类的个数 千行代码数
JhotDraw 6.0b1 300 19
Apache ant v1.6.2 79 566 895
QuickUML2001 8 792 203

Table 6

Design pattern mining of benchmark system"

设计模式 QuickUML 2001 Apache Ant 1.6.2 JHotDraw6.0 1b
基准 本研究 文献[11] 文献[12] 文献[20] 基准 本研究 文献[11] 文献[12] 文献[20] 基准 本研究 文献[11] 文献[12] 文献[20]
Adapter 38 37 34 32 36 65 63 57 59 62 34 32 29 27 31
Command 1 1 1 0 1 4 3 3 2 2 2 2 1 1 1
Factory 1 1 0 0 1 3 2 1 1 1 2 1 1 1 1

Table 7

Average accuracy of three benchmark systems %"

设计模式名称 类型 本研究 文献[11] 文献[12] 文献[20]
adapter 结构型 96.13 87.48 84.80 94.16
Command 行为型 91.67 75.00 33.33 66.67
Factory 创建型 72.23 27.77 27.77 61.10

Table 8

Design pattern of shared instance in QuickUML"

设计模式名称 扮演角色 设计模式参与者位置
Command Command uml.ui.ExportAction
Receiver uml.ui.DiagramContainer
Invoke: java.io.File
Adapter Target uml.ui.ExportAction
Adapter uml.ui.DiagramContainer.OpenAction
Adaptee javax.swing.JMenuItem

Table 9

Benchmark of classical system feature"

系统 KLOC 包数 类的数量 设计模式名称 标准设计模式基准数量 设计模式变体基准数量 共享模式实例基准数量
经典系统1 Adapter 4 2 1
127.52 8 182 Command 2 1 1
Factory Method 1 0 0
经典系统2 Adapter 6 2 2
150.82 11 243 Command 2 1 1
Factory Method 2 1 1
经典系统3 Adapter 8 4 3
210.65 23 382 Command 4 2 2
Factory Method 3 1 1
经典系统4 Adapter 15 7 5
365.87 64 662 Command 6 3 2
Factory Method 4 3 2

Table 10

Design pattern mining of typic system"

测试系统 模式名 基准数 本研究 本研究方法正确率/% 平均正确率/%
标准 变体 共享 标准 变体 共享 标准 变体 共享
经典系统1 Adapter 4 2 1 4 2 1 100 100 100 100
Command 2 1 1 2 1 1 100 100 100 100
Factory 1 0 0 1 0 0 100
经典系统2 Adapter 6 2 2 6 2 1 100 100 50.0 83.3
Command 2 1 1 2 1 1 100 100 100 100
Factory 2 1 1 2 1 0 100 100 0 66.7
经典系统3 Adapter 8 4 3 7 3 2 87.5 75.0 66.7 76.4
Command 4 2 2 3 1 1 75.0 50.0 50.0 58.3
Factory 3 1 1 2 1 1 66.7 100 100 88.9
经典系统4 Adapter 15 7 5 13 6 3 86.7 85.7 60.0 77.5
Command 6 3 2 5 2 1 83.3 66.7 50.0 66.7
Factory 4 3 2 3 2 1 75.0 66.7 50.0 63.9

Fig.6

Comparison of mining accuracy of design patterns between benchmark system and classic system"

Table 11

Average accuracy of four classic systems"

设计模式名称 设计模式类型 平均正确率/%
Adapter模式 结构型 84.30
Command模式 行为型 81.26
Factory Method模式 创建型 73.17
1 LUCIA A D , DEUFEMIA V , GRAVINO C , et al. Detecting the behavior of design patterns through model checking and dynamic analysis[J]. ACM Transactions on Software Engineering and Methodology, 2018, 26 (4): 1- 41.
2 肖卓宇, 何锫. 多阶段可松弛的设计模式变体检测方法[J]. 华中科技大学学报(自然科学版), 2018, 46 (1): 26- 31.
XIAO Zhuoyu , HE Pei . Multi-stage relaxed detection method for variants of design pattern[J]. Journal of Hua zhong University of science and Technology (Natural Science), 2018, 46 (1): 26- 31.
3 MAYVAN B B , RASOOLZADEGAN A , EBRAHIMI A M . A new benchmark for evaluating pattern mining methods based on the automatic generation of testbeds[J]. Information and Software Technology, 2019, 59 (1): 60- 79.
4 肖卓宇, 何锫, 陈俊旭, 等. 设计模式变体检测研究[J]. 小型微型计算机系统, 2017, 38 (8): 1751- 1756.
doi: 10.3969/j.issn.1000-1220.2017.08.018
XIAO Zhuoyu , HE Pei , CHEN Junxu , et al. Research on variants of the design pattern detection[J]. Journal of Chinese Computer Systems, 2017, 38 (8): 1751- 1756.
doi: 10.3969/j.issn.1000-1220.2017.08.018
5 肖卓宇, 何锫, 余波, 等. 一种形式化文法关系驱动的设计模式检测方法[J]. 工程科学学报, 2016, 38 (10): 1499- 1508.
XIAO Zhuoyu , HE Pei , YU Bo , et al. An approach for design pattern detection based on the formal context-free grammar relation driver[J]. Chinese Journal of Engineering, 2016, 38 (10): 1499- 1508.
6 DWIVEDI A K , TIRKEY A , RATH S K . Applying learning-based methods for recognizing design patterns[J]. Innovations in Systems and Software Engineering, 2019, 15 (2): 87- 100.
doi: 10.1007/s11334-019-00329-3
7 MAYVAN B B , RASOOLZADEGAN A , YAZDI Z G . The state of the art on design patterns: a systematic mapping of the literature[J]. Journal of Systems and Software, 2017, 125 (3): 93- 118.
8 肖卓宇, 何锫, 余波. 一种多阶段交互式线索驱动的设计模式识别方法[J]. 北京航空航天大学学报, 2017, 43 (9): 1746- 1756.
XIAO Zhuoyu , HE Pei , YU Bo . A multi-stage approach based on interactive clues driven for design pattern identification[J]. Journal of Beijing University of Aeronautics and Astronautics, 2017, 43 (9): 1746- 1756.
9 肖卓宇, 黄海, 何锫, 等. 设计模式检测工具有效性评估策略[J]. 计算机科学与探索, 2018, 12 (3): 380- 392.
XIAO Zhuoyu , HUANG Hai , HE Pei , et al. Evaluation strategy of efficiency in design pattern detection tools[J]. Journal of Frontiers of Computer Science and Technology, 2018, 12 (3): 380- 392.
10 ZHU H , BAYLEY I . An algebra of design patterns[J]. ACM Transactions on Software Engineering and Methodology, 2013, 22 (3): 23- 61.
11 ZANONI M , FONTANA F A , STELLA F . On applying machine learning techniques for design pattern detection[J]. Journal of Systems and Software, 2015, 88 (5): 102- 117.
12 CHIHADA A , JALILI S , HASHEMINEJAD S M H , et al. Source code and design conformance, design pattern detection from source code by classification approach[J]. Applied Soft Computing, 2015, 26 (1): 357- 367.
13 FONTANA F A , MAGGIONI S , RAIBULET C . Design patterns: a survey on their micro-structures[J]. Journal of Software: Evolution and Process, 2013, 25 (1): 27- 52.
14 FONTANA F A , MAGGIONI S , RAIBULET C . Understanding the relevance of micro-structures for design patterns detection[J]. Journal of Systems and Software, 2011, 84 (12): 2334- 2347.
doi: 10.1016/j.jss.2011.07.006
15 肖卓宇, 何锫, 李港, 等. 注入间接线索的设计模式变体分类检测[J]. 小型微型计算机系统, 2018, 39 (6): 1335- 1341.
doi: 10.3969/j.issn.1000-1220.2018.06.039
XIAO Zhuoyu , HE Pei , LI Gang , et al. Injected Indirect clues for variants of design pattern detection[J]. Journal of Chinese Computer Systems, 2018, 39 (6): 1335- 1341.
doi: 10.3969/j.issn.1000-1220.2018.06.039
16 YU D , ZHANG P , YANG J , et al. Efficiently detecting structural design pattern instances based on ordered sequences[J]. Journal of Systems and Software, 2018, 91 (5): 35- 56.
17 DWIVEDI A K , TIRKEY A , RATH S K . Software design pattern mining using classification-based techniques[J]. Frontiers of Computer Science, 2018, 12 (5): 908- 922.
18 PETTERSON N , L WE W , NIVRE J . Evaluation of accuracy in design pattern occurrence detection[J]. IEEE Transactions on Software Engineering, 2010, 36 (4): 575- 590.
19 肖卓宇, 黎妍, 何锫, 等. 基于矩阵积分评估的设计模式检测研究[J]. 小型微型计算机系统, 2016, 37 (7): 1428- 1433.
XIAO Zhuoyu , LI Yan , HE Pei , et al. Research on matrix grade evaluation based on design pattern detection[J]. Journal of Chinese Computer Systems, 2016, 37 (7): 1428- 1433.
20 MAYVAN B B , RASOOLZADEGAN A . Design pattern detection based on the graph theory[J]. Knowledge-Based Systems, 2017, 120 (1): 211- 225.
21 肖卓宇, 何锫, 杨鑫维, 等. 基于文法产生式优化的设计模式识别方法[J]. 电子科技大学学报, 2017, 46 (3): 569- 576.
XIAO Zhuoyu , HE Pei , YANG Xinwei , et al. An optimization method for design pattern identification based on the grammar production[J]. Journal of University of Electronic Science and Technology of China, 2017, 46 (3): 569- 576.
22 GUÉHÉNEUC Y G. P-mart: pattern-like micro architecture repository[C]//Proceedings of the 1st EuroPLoP Focus Group on pattern repositories. Ottawa, Canada: IEEE, 2007: 1-3.
23 ERICH GAMMA , RICHARD HELM , RALPH JOHNSON , et al. Design pattern: elements of reusable object-oriented software[M]. Bombay, India: Addison Wesley, 1995: 1- 22.
24 DE LUCIA A, DEUFEMIA V, GRAVINO C, et al. Impact of design pattern implementation variants on the retrieval effectiveness of a recovery tool: an exploratory Study[C]//2018 44th Euromicro Conference on Software Engineering and Advanced Applications. Seaa, Prague: IEEE, 2018: 159-166.
25 肖卓宇, 何锫, 余波, 等. 基于FCA与CBR的设计模式检测[J]. 山东大学学报(工学版), 2016, 46 (2): 22- 28.
XIAO Zhuoyu , HE Pei , YU Bo , et al. Design patterns detection based on FCA and CBR[J]. Journal of Shandong University (Engineering Science), 2016, 46 (2): 22- 28.
26 肖卓宇, 何锫, 余波. 非标准设计模式的恢复[J]. 计算机工程与设计, 2019, 40 (1): 143- 148.
XIAO Zhuoyu , HE Pei , YU Bo . Recovery of non-standard design pattern[J]. Computer Engineering and Design, 2019, 40 (1): 143- 148.
27 肖卓宇, 何锫, 黎妍. 基于设计模式角色的附加关系检测研究[J]. 计算机应用研究, 2015, 32 (7): 2042- 2045.
XIAO Zhuoyu , HE Pei , LI Yan . Study on the additional relationships based on design pattern's roles[J]. Application Research of Computers, 2015, 32 (7): 2042- 2045.
[1] HUO Bingqiang, ZHOU Tao, LU Huiling, DONG Yali, LIU Shan. Lung tumor benign-malignant classification based on multi-modal residual neural network and NRC algorithm [J]. Journal of Shandong University(Engineering Science), 2020, 50(6): 59-67.
[2] MA Changxia, ZHANG Chen. Pre-trained based joint model for intent classification and slot filling in Chinese spoken language understanding [J]. Journal of Shandong University(Engineering Science), 2020, 50(6): 68-75.
[3] ZHAO Ningning, TANG Xuesong, ZHAO Mingbo. Depth segment classification algorithm based on convolutional neural network [J]. Journal of Shandong University(Engineering Science), 2020, 50(4): 22-27.
[4] Shiqi SONG,Yan PIAO,Zexin JIANG. Vehicle classification and tracking for complex scenes based on improved YOLOv3 [J]. Journal of Shandong University(Engineering Science), 2020, 50(2): 27-33.
[5] Chao FENG,Kunpeng XU,Lifei CHEN. LDA-based topic feature representation method for symbolic sequences [J]. Journal of Shandong University(Engineering Science), 2020, 50(2): 60-65.
[6] Chunyang LI,Nan LI,Tao FENG,Zhuhe WANG,Jingkai MA. Abnormal sound detection of washing machines based on deep learning [J]. Journal of Shandong University(Engineering Science), 2020, 50(2): 108-117.
[7] Mingxia GAO,Jingwei LI. Chinese short text classification method based on word2vec embedding [J]. Journal of Shandong University(Engineering Science), 2019, 49(2): 34-41.
[8] Qingtao QU,Qicheng LIU,Chunxiao MU. A parallel adaptive news topic tracking algorithm based on N-Gram language model [J]. Journal of Shandong University(Engineering Science), 2018, 48(6): 37-43.
[9] Yao LI,Zhihai WANG,Yan′ge SUN,Wei ZHANG. An adaptive ensemble classification method based on deep attribute weighting for data stream [J]. Journal of Shandong University(Engineering Science), 2018, 48(6): 44-55, 66.
[10] Dongbo ZHANG,Tao KOU,Haixia XU. Fast scene recognition based on LDB descriptor and local spatial structure matching [J]. Journal of Shandong University(Engineering Science), 2018, 48(5): 16-23.
[11] Pu ZHANG,Chang LIU,Yong WANG. Suggestion sentence classification model based on feature fusion and ensemble learning [J]. Journal of Shandong University(Engineering Science), 2018, 48(5): 47-54.
[12] YE Mingquan, GAO Lingyun, WAN Chunyuan. Gene expression data classification based on artificial bee colony and SVM [J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2018, 48(3): 10-16.
[13] WANG Huan, ZHOU Zhongmei. An over sampling algorithm based on clustering [J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2018, 48(3): 134-139.
[14] CAO Ya, DENG Zhaohong, WANG Shitong. An radial basis function neural network model based on monotonic constraints [J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2018, 48(3): 127-133.
[15] XIE Zhifeng, WU Jiaping, MA Lizhuang. Chinese financial news classification method based on convolutional neural network [J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2018, 48(3): 34-39.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
[1] WANG Su-yu,<\sup>,AI Xing<\sup>,ZHAO Jun<\sup>,LI Zuo-li<\sup>,LIU Zeng-wen<\sup> . Milling force prediction model for highspeed end milling 3Cr2Mo steel[J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2006, 36(1): 1 -5 .
[2] ZHANG Yong-hua,WANG An-ling,LIU Fu-ping . The reflected phase angle of low frequent inhomogeneous[J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2006, 36(2): 22 -25 .
[3] HAN Xue. Example analysis for landslide hazard remote monitoring at  the Pingzhuang west open-pit mine[J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2009, 39(4): 116 -120 .
[4] KONG Xiang-zhen,LIU Yan-jun,WANG Yong,ZHAO Xiu-hua . Compensation and simulation for the deadband of the pneumatic proportional valve[J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2006, 36(1): 99 -102 .
[5] CHEN Rui, LI Hongwei, TIAN Jing. The relationship between the number of magnetic poles and the bearing capacity of radial magnetic bearing[J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2018, 48(2): 81 -85 .
[6] JI Tao,GAO Xu/sup>,SUN Tong-jing,XUE Yong-duan/sup>,XU Bing-yin/sup> . Characteristic analysis of fault generated traveling waves in 10 Kv automatic blocking and continuous power transmission lines[J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2006, 36(2): 111 -116 .
[7] QIN Tong, SUN Fengrong*, WANG Limei, WANG Qinghao, LI Xincai. 3D surface reconstruction using the shape based interpolation guided by maximal discs[J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2010, 40(3): 1 -5 .
[8] LIU Wen-liang, ZHU Wei-hong, CHEN Di, ZHANG Hong-quan. Detection and tracking of moving targets using the morphology match in radar images[J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2010, 40(3): 31 -36 .
[9] Yue Khing Toh1, XIAO Wendong2, XIE Lihua1. Wireless sensor network for distributed target tracking: practices via real test bed development[J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2009, 39(1): 50 -56 .
[10] LI Fangjia, GAO Shangce, TANG Zheng*, Ishii Masahiro, Yamashita Kazuya. 3D similar pattern generation of snow crystals with cellular automata[J]. JOURNAL OF SHANDONG UNIVERSITY (ENGINEERING SCIENCE), 2009, 39(1): 102 -105 .