既存ソフトウェア資産活用時代のための ソフトウェア検索システム

65
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 既既既既既既既既既既既既既既既既既既 既既既既既既既既既既既既 既既既既 既既既既

Upload: bianca

Post on 22-Jan-2016

43 views

Category:

Documents


0 download

DESCRIPTION

既存ソフトウェア資産活用時代のための ソフトウェア検索システム. 大阪大学  井上克郎. ソフトウェア空間. SourceForge. 巨大なオープンソース開発支援サイト ソフトウェア検索、版管理、連絡支援 ... プロジェクト数 ≧ 24 万件 ユーザー数 ≧  260 万人. ソフトウェア空間. プログラムの種類 可算無限個ある しかし、よく似たプログラムを繰り返し同じ組織や違う場所で作っている(ような気がする) 昔同じようなプログラム作ったような記憶 もっと良いプログラムがネットにあった. ソフトウェアの蓄積と管理. 蓄積 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

既存ソフトウェア資産活用時代のための

ソフトウェア検索システム

大阪大学  井上克郎

Page 2: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

ソフトウェア空間

2

Page 3: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University3

SourceForge•巨大なオープンソース開発支援サイト•ソフトウェア検索、版管理、連絡支援 ...

 プロジェクト数 ≧  24万件ユーザー数 ≧  260万人

Page 4: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

ソフトウェア空間•プログラムの種類•可算無限個ある

•しかし、よく似たプログラムを繰り返し同じ組織や違う場所で作っている(ような気がする)– 昔同じようなプログラム作ったような記憶–もっと良いプログラムがネットにあった ...

4

Page 5: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

ソフトウェアの蓄積と管理蓄積•社内資産をレポジトリに保存•オープンソースプロジェクトとして公開保存何でもとりあえず貯めることで、比較的簡単

管理•ソフトウェア部品の登録・整備•開発資産の整理同類をまとめる、違うものを分類することは、知恵、努力が必要であまりうまくいかない

5

Page 6: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

ソフトウェア空間の探索• 閲覧(ブラウジング)

– 整理されていることが前提• 名前• 時間• 種類

– あまり現実的ではない?• 検索(サーチ)大量の候補の中から求めるものを見付ける– 検索のキーをユーザーが提供する– ユーザの開発作業のコンテキストからキーを見つけ自動的に推薦

6

Page 7: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

検索の手法• キーワード検索

– 関数、クラス名– パラメーター– 変数– コメント

• プログラム断片検索– 不完全な構造– 完全なプログラム

いずれにせよ計算機パワーで多量なデータの分析・整理が必要

7

 ...31    @author Ceki Gülcü */32 public class SortAlgo {33 34   final static String className = SortAlgo.class.getName();35   final static Logger LOG = Logger.getLogger(className);36   final static Logger OUTER = Logger.getLogger(className + ".OUTER");37   final static Logger INNER = Logger.getLogger(className + ".INNER");38   final static Logger DUMP = Logger.getLogger(className + ".DUMP");39   final static Logger SWAP = Logger.getLogger(className + ".SWAP");40 41   int[] intArray;42 43   SortAlgo(int[] intArray) {44     this.intArray = intArray;45   }46... 

Page 8: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

関連研究(1 )

ソフトウェアサーチエンジン• Google, Google Code Search (Google)• Koders (Black Duck)

– 3GB OSS, C/C++/C#/... 30言語

• Krugle (Krugle Enterprise)– OSSプロジェクトサポート、サーチエンジン

• SourceForge (Geeknet Inc.)• SPARS/J

– 阪大、他のコードサーチエンジンより先行

• CodeBroker, Sourcerer, Merobase, Exemplar, Strathcona, Assieme, XSnippet, ...

8

Page 9: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

関連研究(2 )

ソフトウェア部品推薦• Historical Approachユーザの履歴、利用実績を収集し、–そのまま提供–ユーザのパターンを協調フィルタリング等で選別して提供

• Social Approach開発者やユーザのネットワークを作ってエキスパートに聞く

9

Page 10: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

関連研究(3 )

ソフトウェア部品のランキング•被参照数

– 参照するものによって価値付け•コンポーネントランク、ページランク

– 高い価値のあるものに参照されるものは価値が高くなる

•参加した開発者の価値– Karma Value:開発者ごとの価値

10

Page 11: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

計算ソフトウェア工学• Computation Intensive Software Engineering CISE• 高い品質のソフトウェアを効率よく作るために

– 高い計算能力の環境を使う– 大規模なデータを扱う

• オープンソースソフトウェア• 開発データ …

• 例– Search-based software engineering– Mining software repositories– Empirical approaches to software

engineering

11

Page 12: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

計算ソフトウェア工学の背景• ソフトウェア工学という言葉が生まれて 40年• どれだけ進歩したか?

– ICSE40 周年  40年前の議論は、多くは今も通じる– 小規模な改善:ターゲットは個人、プロジェクト

• 大きく変わったのはハードウェア環境• 巨大な CPUパワーとディスク容量、高速ネットワーク• ソフトウェアに関する人間の英知が、ソフトウェア生産物に凝縮されているとすれば、今まで、人間が営々として構築してきた、ソフトウェアに関する全ての英知を、集積することは不可能ではない???

• 強力なネットワークを利用して、入手可能なソフトウェア生産物を集め、解析すれば、ソフトウェアに関する深い知見が生まれないか??? e.g., ソフトウェアの変遷等

• ソフトウェアの構築にもいろいろな可能性を探索し、組み合わせの可能性を広く探る構成的開発はできないか?

• 計算機パワーに依存した、計算を主体としたソフトウェア工学手法  ⇒ 計算ソフトウェア工学

• 素人には手出しできない、プロの SE 領域確立したい

Page 13: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

ソフトウェア工学の規模scale

Collection Analysis Improvement

scale

Collection Analysis Improvement

4

23

65

4

23

65

Multiple project data expertise extraction Organizational improvement

Personal activity data Problem detectionTool customisation/activity navigation

Personal activity data Problem detectionTool customisation/activity navigation

Single project data Progress estimationProcess/product

improvementSingle project data Progress estimationProcess/product

improvement

Page 14: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

SPARS-J

14

Page 15: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University15

•使えるソフトウェアライブラリを集めてくる

•集めたライブラリの内部や外部との関係を詳しく解析する

•ライブラリの部品ごとに、その有用度をランク付け

•ユーザーからのキーワードによる問い合わせに対して、ランクに応じた回答

賢いソフトウェアライブラリ

Component Rank Model

Page 16: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University16

コンポーネントグラフ

A B

C

ED

F

G

IH

System X System Y

component

use relation

Page 17: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University17

頂点の重み

A B

C

ED

F

G

IH

System X System Y

全頂点の重み合計 = 1 ... (1)重みが重要度を示す指標

0.10.1

0.2

0.1 0.1

0.1

0.2

0.050.05

1 w(x) 0

Page 18: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University18

辺の重み

A0.2

0.05

0.05

0.05

0.05

B

0.2

0.05

0.15

0.4

d=1/4

d=1/4

d=1/4

d=1/4

d: 分配率

w(A)  = 全出力辺の重みの合計     ... (2)全入力辺の重みの合計 = w(B) ... (3)

Page 19: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University19

重みの定義• (1)~(3)の制約に基づく連立方程式が得られる

)(

)(

)(

2

1

nvw

vw

vw

)(

)(

)(

2

1

nvw

vw

vw

t

ddd

ddd

ddd

nnnn

n

n

21

22221

11211

= .

Dt: transposed matrix of      distribution ratio

W: node weight vector

Page 20: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University20

重みの伝播

A B

C

0.34 0.33

0.33

0.17

0.17

0.330.33

Page 21: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University21

重みの伝播

A B

C

0.33 0.17

0.5

0.175

0.175

0.170.5

Page 22: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University22

重みの伝播

A B

C

0.5 0.175

0.345

0.25

0.25

0.1750.345

Page 23: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University23

重みの伝播

A B

C

0.4 0.2

0.4

0.2

0.2

0.20.4

安定した重み ( 固有ベクトル )Component Rank : 重みによる頂点の順序

Page 24: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University24

マルコフモデル

• ユーザ視点のマルコフ連鎖

• 一定時間でどこに移動するか

• 頂点の重みはユーザ視点がどれだけその頂点に留まっているかを示す

0.01

0.02 0.01

0.030.05

0.001 0.1

Page 25: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University25

疑似利用関係

A B C

• 計算収束のために付加する

• 各頂点から(つながっていない)全頂点へ

)edgereal()edgepseudo( ww

Page 26: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University26

部品の集約C

B

A

G

F

D E

部品グラフ

C

BF

AD E

G

集約部品グラフFB  D,A

Page 27: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University27

コンポーネントランクの評価システム

similarity measureby SMMT

use relationextraction 

clusteringclustered graph construction 

node weightcomputation

de-clustering to original graph

input

output

.java file =    component

component-rank pairs

•inheritance•method call•attribute access•abstract class impl.

weight ratio p between real and pseudo edges : 0.85 

similarity criterion t: sharing 80% statements

equal distribution ratio d to outgoing edges

Page 28: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University28

実験 1

JDK1.3.0575,000 lines, 1877 components7 minutes on PC (Pentium IV, 2GHz, 2GB)

1 java.lang.Object 0.161262 java.lang.Class 0.087123 java.lang.Throwable 0.055104 java.lang.Exception 0.031035 java.io.IOException 0.013436 java.lang.StringBuffer 0.012147 java.lang.SecurityManager 0.011698 java.io.InputStream 0.010279 java.lang.reflect.Field 0.0094810 java.lang.reflect.Constructor 0.00936 ... ...1256 sunw.util.EventListener 0.00011 ... ...1256

rank class name weight

Page 29: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University29

実験 2:

ある企業のライブラリ• Javaアプリケーション開発用フレームワークとそのアプリケーション

• 5 applications + framework– 1538 components, 339 clustered nodes

•フレームワーククラスとそのデータ構造定義のクラスが高いランク

Page 30: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University30

議論 1:

重み計算モデル

B

A

E D C

B

A

E D C

Component Rank ModelReference Count Model

0.2

0.6

0 0 0.2 0.03 0.03 0.30

0.33

0.31

Page 31: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University31

議論 2:

集約方法 (1)

• 単純な重複部品は消去される

A

B

A

B

X

Y

original copy others

A

B

X

Y

0.25 0.25

0.250.25

Clustering

Page 32: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University32

• 他の環境で再利用されるものは重みが加わる

A

B

A

C

X

Y

original modified others

A

B

X

Y

0.3 0.2

0.20.15

C

0.15

Clustering

議論 2:

集約方法 (2)

Page 33: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University33

議論 3:

類似度や疑似利用関係• 得られるランキングは類似度の基準 t には敏感ではない– t が 0.8 以下だと異なる部品が同じクラスタに入る

•いろいろな擬似利用辺の重みの割合 p で実験– p が 0.75 - 0.95の間で安定している

Page 34: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University34

関連する考え• 文書の視点の移動マルコフモデル

– Influence Weight: 論文・文献の価値– Page Rank: インターネット上でのWebの価値明確な利用関係を使っている集約の考えない(ソフトウェアでは集約は重要)

• 再利用性の指標– 部品やそのインターフェースを利用したいろいろな

指標が提案されている間接的な指標(コンポーネントランクは直接指標)

Page 35: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

SPARS-J• Software Product Archive, Analysis,

and Retrieve System for Java• 新しい発想に基づいたソースコード蓄積・検索システム

• Javaを対象に• 日々の管理は全自動• 静的解析技術を用いて広域の依存関係抽出•メトリクス技術を用いて類似部品抽出

35

Page 36: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

SPARS-Jのランク手法•コンポーネントランク CR•検索語の重要度( TF-IDF)

   CR + TF-IDF

36

Page 37: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

SPARS-Jの概要

Javaファイル群 依存関係

キーワード解析・登録

レポジトリキーワード検索パッケージ階層表示 Webブラウザ

ユーザー

SPARS-J

登録 検索

表示

37

Page 38: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

SPARS-Jの機能の概要(登録)• Javaの1クラス ( * .java) = 検索単位 :部品

• 指定したファイル群やディレクトリ群に含まれる部品の自動検索

•クラス間の関係(継承,インターフェース,呼び出し,参照等)の解析

•部品内に含まれるキーワードの抽出• DB( Berkeley DB)に登録

38

Page 39: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

SPRAS-Jの機能(検索・表示)•キーワード検索/パッケージ木ブラウズ•部品のソース,呼ばれている・呼んでいるクラス・メソドの表示や各種メトリクス表示

• 条件付検索(クラス名,コメント, )・・・• 重要な部品を上位に表示•部品間の類似度を計測―同一部品集約• 日本語/英語両用

39

Page 40: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

SPARS-J検索入り口

40

Page 41: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

検索結果表示

41

Page 42: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

パッケージブラウザ

42

メソッド一覧メソッド定義行へ移動

パッケージブラウザサブパッケージ一覧クラス一覧

Page 43: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka UniversitySPARS 技術解説 43

部品詳細表示 ( 類似部品群 )

Page 44: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka UniversitySPARS 技術解説 44

部品詳細表示 ( 利用する部品 )

Page 45: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka UniversitySPARS 技術解説 45

部品詳細表示 ( 利用される部品 )

Page 46: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka UniversitySPARS 技術解説 46

部品詳細表示 ( メトリクス )

Page 47: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

SPARS-Jの利用イメージ• 一つの開発中のプロジェクトのソース管理

– 他人が作った部品が見える– 前の版も調べられる

• 過去の類似プロジェクトのソース管理– 部品の依存関係が分かる– 再利用率,新規開発率が分かる

•組織の全プロジェクトのソース管理– 何か使われて何がいらないか– 全資産量はどれだけあるか

47

Page 48: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

適用例•研究室内の Javaの資産管理•インターネット上から入手できるプログラムの検索( 18万クラス)

•あるソフトウェアハウスの Javaフレームワークにおける資産管理

•ある食品系会社の Java資産管理...

48

Page 49: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

類似コード

49

Page 50: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

コードの類似性難しい課題•構文的に似ている•意味的に似ている•全体が似ている•部分的に似ている•類似の閾値は…

50

Page 51: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

コードクローンとは ?• 同型のコード断片を(同一または他の)のファイルに持つコード断片

• いろいろな理由で存在– コピー&ペースト– 定型のコーディング

ex. file open, DB connect, …– 効率向上のためにわざと

• プログラムの保守をより難しくする要因– 一箇所のコード断片に問題があれば、他の部分も問題ある場合が多い

• よく見逃しがち

code clonecopy-and-paste

51

Page 52: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

52

簡単な例 AFG::AFG(JaObject* obj) { objname = “afg"; object = obj;}AFG::~AFG() { for(unsigned int i = 0; i < children.size(); i++) if(children[i] != NULL) delete children[i];

...

for(unsigned int i = 0; i < nodes.size(); i++) if(nodes[i] != NULL) delete nodes[i];} 52

Page 53: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

53

コードクローンの定義• 簡単な統一的な定義はない(いろいろな研究者が定義)• しかし、おおまかな統一認識

• Type 1 clone: コメント、空白等を除き文字列的に同一• Type 2 clone: 固有名を正規化して同一( parameterized)• Type 3 clone: 意味的に同一または途中に行を挿入したり削

除したもの

• いろいろな検出法1. 行ごとの照合 (type 1)2. AST (Abstract Syntax Tree)の比較 (type 2, 3)3. PDG (Program Dependency Graph)の比較 (type 3)4. メトリクス値の比較 (type 3)5. トークン列比較 (type 2)

53

Page 54: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

54

コードクローン検出ツールCCFinder

• 企業からのニーズ– 巨大システムの保守

• 1000万行、 20年以上• 横並びリストを主導で保守、しかし…

• トークン列照合を行うツール CCFinder, CCFinderX– 固有名の正規化– ユーザー定義名の正規化– テーブル初期化等の無用部分の除去– モジュールの切れ目の認識– 接尾木アルゴリズム (Suffix-tree algorithm)による照合

• CCFinderは数百万行のコードを 5 ~ 30分で分析

54

Page 55: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

55

適用例 1:

FreeBSD, NetBSD, LinuxFreeBSD 4.0 Linux 2.4.0 NetBSD 1.5

Fre

eBSD

4.0

Lin

ux

2.4.

0N

etB

SD

1.5

55

Page 56: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

56

BSD Unix OSの歴史

56

Page 57: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

57

クローン率を距離としたクラスター分析による系統木

57

Page 58: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

58

FreeBSDのアプリケーション集 (Ports Collection)

10.8GB/403M LOC in C10.8GB/403M LOC in C

Livieri, S., Higo, Y., Matsushita, M., Inoue, K., “Very-Large Scale Code Clone Analysis and Visualization of Open Source Programs Using Distributed CCFinder: D-CCFinder“, International Conference on Software Engineering, Minneapolis, MN. (May 2007, to appear)

Livieri, S., Higo, Y., Matsushita, M., Inoue, K., “Very-Large Scale Code Clone Analysis and Visualization of Open Source Programs Using Distributed CCFinder: D-CCFinder“, International Conference on Software Engineering, Minneapolis, MN. (May 2007, to appear)

Page 59: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

59

136 Linux カーネル7.4GB260M LOC in C

7.4GB260M LOC in C

59

Page 60: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

コーディングパータン抽出の例

createUndoActivity()setUndoActivity()getUndoActivity()setAffectedFigures()

コーディングパターン

public void reverseAction(Figure figure) {  setUndoActivity(createUndoActivity());  List l = CollectionsFactory.current().createList();  l.add(figure);  l.add(((DecoratorFigure)figure).peelDecoration());  getUndoActivity().setAffectedFigures(    new FigureEnumerator(l));  ((BorderTool.UndoActivity)getUndoActivity())    .replaceAffectedFigures();}

public void execute() {  super.execute();  setUndoActivity(createUndoActivity());  getUndoActivity()    .setAffectedFigures(view().selection());  FigureEnumeration fe     = getUndoActivity().getAffectedFigures();  …}

シーケンシャルパターンマイニング

60 60

Page 61: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

類似コード片の検索(単語の共起関係の利用)

• モジュール中で共起する識別子対を推移的に求めて関連語とする

単語の共起回数の分布に基づいて関連語を求める

モジュール A モジュール B...host = host_alloc(...);log(...);

if (!add_host(host)) {// scan_host(host)// is missing!}...

host...node = node_alloc(...);if (...) {    return;}if(!add_node(node)) {// scan_node(node)// is missing!}...

nodehost host

host host

node node

node node

61 61

Page 62: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

まとめ

Page 63: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

話した内容•ソフトウェア空間

–ソフトウェア部品検索• SPRAS-J

–コンポーネントランク–キーワード検索

•類似コード– CCFinder– 類似コード片検索

63

Page 64: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

ソフトウェア検索システム•いろいろなアプローチ•大規模計算が前提 → 計算ソフトウェア工学

• OSSや社内資産管理に活躍•ソフトウェア開発の効率化、開発ソフトウェアの高信頼化に必須の技術

64

Page 65: 既存ソフトウェア資産活用時代のための ソフトウェア検索システム

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University

リソース•論文

–Katsuro Inoue, Reishi Yokomori, Tetsuo Yamamoto, Makoto Matsushita, Shinji Kusumoto: "Ranking Significance of Software Components Based on Use Relations", IEEE Transactions on Software Engineering, Vol.31, No.3, pp.213-225, 2005.

–横森 励士 , 梅森 文彰 , 西 秀雄 , 山本 哲男 , 松下 誠 , 楠本 真二 , 井上 克郎 : "Javaソフトウェア部品検索システム SPARS-J", 電子情報通信学会論文誌 D-I, VolJ87-D-I, No.12, pp1060-1068, 2004.

–井上克郎 , 神谷年洋 , 楠本真二 : "コードクローン検出法 ", コンピュータソフトウェア , Vol.18, No.5, pp.47-54, September 2001.(http://sel.ist.osaka-u.ac.jp/~lab-db/betuzuri/archive/349/349.pdf).

–T. Kamiya, S. Kusumoto, and K. Inoue, CCFinder: A multi-linguistic token-based code clone detection system for large scale source code, IEEE Transactions on Software Engineering, vol. 28, no. 7, pp. 654-670, Jul. 2002.

•WEB– SPARS http://www.spars.info/–CCFinderXhttp://www.ccfinder.net/ccfinderxos-j.html

–CCFinderhttp://sel.ics.es.osaka-u.ac.jp/cdtools/index.html

65