Department of Computer Science Graduate School of Information
- Slides: 31
メソッド呼び出しパターンとして現れる 横断的関心事の検出 大阪大学 三宅達也 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University SIGSS研究会
研究背景 n 横断的関心事 n アスペクト指向プログラミング(AOP) n メソッド呼び出しパターン SIGSS研究会 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 3
横断的関心事 n 複数のモジュールにまたがって実装される 機能 n 保守性,再利用性などを悪化させる クラス1 クラス 2 ロギング 例外処理 SIGSS研究会 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 4
横断的関心事の例 Class cls 1 { void method 1 ( ) { logging. message(); logging. message( “meth 1”); } ・ ・ ・ } コンパイル エラー Class Logging { public void message(String ){ s) { System. out. println(“start”); System. out. println(s); } } メソッドの開始時にメ ッセージを 表示するメソッド Class cls 2 { void method 2 ( ) { logging. message(); logging. message( “meth 2”); } } ・ ・ ・ 本来はLoggingクラス にまとめてしまいたい SIGSS研究会 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 5
横断的関心事の種類の例 ~ Homogeneous と Heterogeneous ~ 均一性横断的関心事 非均一性横断的関心事 public void heterogen 1 ( ) { double res; Line. Data ld = input ( ); boolean c = ld. check( ); int h = ld. get. Height( ); int b = ld. get. Bottom( ); if ( c ) { res = b * h / 2; output ( res ); } } public void homogen 1 ( ) { if ( is. Log() ) { show. Log ( ); } int r = ld. get. Radius( ); res = Math. pow ( r, 2 ); res = res * Math. PI; } public void homogen 2 ( ) { if ( is. Log() ) { show. Log ( ); } int h = ld. get. Height( ); int b = ld. get. Bottom( ); res = b * h / 2; } SIGSS研究会 public void heterogen 2 ( ) { double res; Line. Data ld = input ( ); Id. hoge(); boolean c = ld. check( ); if ( c ) { int r = ld. get. Radius( ); res = Math. pow ( r, 2 ); res = res * Math. PI; output ( res ); } } 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 8
メソッド呼び出しパターンの例 Public void circle ( ) { Public void triangle ( ) { 辺の長さを double res; 読み込む Line. Data ld = input ( ); boolean c = ld. check( ); 長さの例外 if ( c ) { int h = ld. get. Height( ); チェック int r = ld. get. Radius( ); int b = ld. het. Bottom( ); 求めた面積 res = Math. pow ( r, 2 ); if ( c ) { を出力 res = res * Math. PI; res = b * h / 2; output ( res ); } メソッド呼び出しパターン } } } input( ) Line. Data. check( ); if output; } SIGSS研究会 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 10
Sequential pattern mining(Prefix. Span) n 特徴シーケンスに対し射影と呼ばれる操作を繰 り返し行なうことでシーケンシャルパターンを抽 出する p 射影とは,全てのシーケンスに対して特定の要素 からの接尾辞を取り出す操作 要素aによる射影 acd cd abc bc 要素aの 接尾辞 cba aab ab SIGSS研究会 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 15
Prefix. Spanの例 n 最低出現回数2、最小要素数1 ab,ac,を パターンとして出力 a,b,c,を パターンとして出力 1. a c d 2. a b c 3. c b a 4. a a b a: 4 b: 3 c: 3 d: 1 各要素の 出現回数 1. c d 2. b c 4. a b a: 1 b: 2 c: 2 d: 1 2. c 3. a a: 1 c: 1 1. d 1. b a a: 1 b: 1 d: 1 射影 SIGSS研究会 2. c c: 1 1. d d: 1 結果 a : 4 ab: 2 ac: 2 b : 3 c : 3 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 16
抽出されたメソッド呼び出しパターンの例 (横断的関心事に関連しているパターン1) n 呼び出されているメソッドの名前に特定のキーワードが多数出現 実行コマンド取消用の情報を 保存するためのパターン Abstract. Command. set. Undo. Activity() Abstract. Command. get. Undo. Activity() Undoable. set. Affected. Figures() Abstract. Command. get. Undo. Activity() Undoable. get. Affected. Figures() SIGSS研究会 キーワードUndo が多数出現 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 21
抽出されたメソッド呼び出しパターンの例 (横断的関心事に関連しているパターン2) n パターンが出現するメソッドの名前に特定のキーワードが多数出現 マウス操作に関連する パターン Mouse. Event. get. X() Mouse. Event. get. Y() 抽出 抽出 抽出 class Connection. Tool{ ・・・・・・ public void mouse. Up{ ・・・・・ } } class Polygon. Tool{ ・・・・・・ public void mouse. Down{ ・・・・ } } キーワードmouse が多数出現 class Drawing. View. Mouse. Listener{ ・・・・・・ public void mouse. Pressed{ ・・・・ } } SIGSS研究会 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 22
抽出されたメソッド呼び出しパターンの例 (アプリケーションの機能に関連していないパターン) org. jhotdraw. standard. Standard. Drawing. View public void add. All(Collection figures) { Figure. Enumeration fe = new Figure. Enumerator(figures); while (fe. has. Next. Figure()) { add(fe. next. Figure()); } } 集合がまだ要素を持 っているかどうかチェ ック メソッド呼び出しパターン (出現回数 59) org. jhotdraw. standard. Composite. Figure public Figure. Enumeration figures(Rectangle view. Rectangle) { if (_the. Quad. Tree != null) { Figure. Enumeration fe = _the. Quad. Tree. get. All. Within(new Bounds(view. Rectangle( List l 2 = Collections. Factory. current(). create. List(); while (fe. has. Next. Figure()) { Figure f = fe. next. Figure(); //int z = f. Figures. index. Of(f); l 2. add(new Ordered. Figure. Element(f, f. get. ZValue())); } ・ } 集合の 次の要素を取得 Figure. Enumeration. has. Next. Figure() while Figure. Enumeration. next. Figure() } 繰り返しの制御に 関連するパターン (横断的関心事というよりは イディオム) SIGSS研究会 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 23
クラスを区別せずに抽出したパターンの例 org. jhotdraw. figures. Border. Tool org. jhotdraw. standard. Duplicate. Command public void execute() { super. execute(); set. Undo. Activity(create. Undo. Activity()); Figure. Selection selection = view(). get. Figure. Sele・・・ public void action(Figure figure) { // Figure replace. Figure = drawing(). replace(figur ・・ set. Undo. Activity(create. Undo. Activity()); List l = Collections. Factory. current(). create. List(); l. add(figure); l. add(new Border. Decorator(figure)); get. Undo. Activity(). set. Affected. Figures(new Fig ・・ ((Border. Tool. Undo. Activity)get. Undo. Activity()). repl ・・ // create duplicate figure(s) Figure. Enumeration figures = (Figure. Enumeration) ・・ get. Undo. Activity(). set. Affected. Figures(figures); view(). clear. Selection(); ・・・・・・・・・・・・・・・ } Abstract. Tool のサブクラス } Abstract. Command のサブクラス org. jhotdraw. standard. Resize. Handle set. Undo. Activity() create. Undo. Activity() get. Undo. Activity. I() set. Affected. Figures() public void invoke. Start(int x, int y, Drawing. View view) { set. Undo. Activity(create. Undo. Activity(view)); get. Undo. Activity(). set. Affected. Figures(new Sing ・・ ((Resize. Handle. Undo. Activity)get. Undo. Activity()). se・・・ } Abstract. Handle のサブクラス SIGSS研究会 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 25
クラスを区別せずに抽出したパターン Abstract Command 11サブクラスに存在 Abstract Handle 6サブクラスに存在 Abstract Tool 9サブクラスに存在 Abstract. Command. set. Undo. Activity() Abstract. Handle. set. Undo. Activity() Abstract. Tool. set. Undo. Activity() Each. Sub. Class. create. Undo. Activity() Abstract. Command. get. Undo. Activity. I() Abstract. Handle クラスを識別しない場合の. get. Undo. Activity. I() パターン Abstract. Tool. get. Undo. Activity. I() Undoable. set. Affected. Figures() Undoable set. Undo. Activity(). set. Affected. Figures() create. Undo. Activity() get. Undo. Activity. I() set. Affected. Figures() SIGSS研究会 Undoable. set. Affected. Figures() 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 26
既存手法との比較(抽出例) 同一のメソッド呼び出しパターンを持つコード org. jhotdraw. standard. Cut. Command public void execute() { super. execute(); set. Undo. Activity(create. Undo. Activity()); Figure. Enumeration fe = view(). selection(); List affected = Collections. Factory. current(). create. L・・・ Figure f; Figure. Enumeration dfe; while (fe. has. Next. Figure()) { f = fe. next. Figure(); affected. add(0, f); dfe = f. get. Dependend. Figures(); ・・・・・・・・・・・ } fe = new Figure. Enumerator(affected); get. Undo. Activity(). set. Affected. Figures(fe); Undo. Activity ua = (Undo. Activity) get. Undo. Activity(); ua. set. Selected. Figures(view(). selection()); copy. Figures(ua. get. Selected. Figures(), ua. get. Sele・・・・ delete. Figures(get. Undo. Activity(). get. Affected. Figures()); view(). check. Damage(); } コードクローンベースの手法で抽出できるコード org. jhotdraw. fiures. Group. Command public void execute() { super. execute(); set. Undo. Activity(create. Undo. Activity()); get. Undo. Activity(). set. Affected. Figures(view(). selection()); ((Group. Command. Undo. Activity)get. Undo. Activity()). group・・・ view(). check. Damage(); } org. jhotdraw. standard. Align. Command public void execute() { super. execute(); set. Undo. Activity(create. Undo. Activity()); get. Undo. Activity(). set. Affected. Figures(view(). selection()); ((Align. Command. Undo. Activity)get. Undo. Activity()). align. A・・・ view(). check. Damage(); } SIGSS研究会 10/26/2021 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 30
- Oussep
- Ucl ridgmount practice
- Northwestern electrical engineering
- Computer science department rutgers
- Meredith hutchin stanford
- Fsu computer science department
- Trimentoring
- Department of computer science christ
- Mice.cs.columbia
- What s your favorite subject
- Aka mip
- Lsu dissertation guidelines
- Sgs academic upm
- Graduate school korea university
- Georgia high school requirements
- Jesus seminary
- Uaf thesis format
- Usf admission portal
- Nau graduate housing
- Wesley horng
- Uf writing studio
- Ajou university gsis
- Time management in graduate school
- Keller graduate school of mgmt
- Kisses of death for the graduate school application
- Nau family housing
- Tgs utwente
- Towson university phd programs
- Rutgers handshake
- Ics graduate school
- Efi arazi school of computer science
- Erik jonsson school of engineering and computer science