B 4 Department of Computer Science Graduate School
メソッド呼び出しパターンとして現れる 横断的関心事の特徴評価 井上研究室 B 4 三宅達也 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 2007/02/27 卒業論文発表会
研究背景 n アスペクト指向プログラミング(AOP) n 横断的関心事 n メソッド呼び出しパターン 卒業論文発表会 2007/02/27 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 2
横断的関心事の例 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クラス にまとめてしまいたい 卒業論文発表会 2007/02/27 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 5
メソッド呼び出しパターンの例 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; } 卒業論文発表会 2007/02/27 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 8
抽出されたメソッド呼び出しパターンの例 (機能に関連しているパターン) 実行コマンド取り消しのための情 報を保存するためのパターン (アスペクト候補) org. jhotdraw. standard. Send. To. Back. Command コマンド実行 public void execute() { super. execute(); set. Undo. Activity(create. Undo. Activity()); get. Undo. Activity(). set. Affected. Figures(view(). selection. ZOrdered()); Figure. Enumeration fe = get. Undo. Activity(). get. Affected. Figures(); while (fe. has. Next. Figure()) { view(). drawing(). send. To. Back(fe. next. Figure()); } view(). check. Damage(); } 実行コマンド取り消しの ための情報を保存 org. jhotdraw. standard. Paste. Command 実行コマンドの処理 public void execute() { super. execute(); Point last. Click = view(). last. Click(); Figure. Selection selection = (Figure. Selection)Clipboard. get. Clipboard(). get. Conten; if (selection != null) { set. Undo. Activity(create. Undo. Activity()); get. Undo. Activity(). set. Affected. Figures( (Figure. Enumerator)selection. get. Data(Standard. Figure. Selection. TYPE)); if (!get. Undo. Activity(). get. Affected. Figures(). has. Next. Figure()) { set. Undo. Activity(null); return; } 実行コマンドがビューに 与えた影響をチェック Rectangle r = get. Bounds(get. Undo. Activity(). get. Affected. Figures()); view(). clear. Selection(); メソッド呼び出しパターン Abstract. Command. execute() Abstract. Command. set. Undo. Activity() Abstract. Command. get. Undo. Activity() Undoable. set. Affected. Figures() Abstract. Command. get. Undo. Activity() Undoable. get. Affected. Figures() Figure. Enumeration. has. Next. Figure() Abstract. Command. view() Drawing. View. check. Damage() Figure. Enumeration fe = insert. Figures(get. Undo. Activity(). get. Affected. Figures() get. Undo. Activity(). set. Affected. Figures(fe); view(). check. Damage(); } } 卒業論文発表会 実行コマンドがビューに与えた影 響をチェックするためのパターン 2007/02/27 (アスペクト候補) Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 13
抽出されたメソッド呼び出しパターンの例 (機能に関連していないパターン) 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() } 集合の 次の要素を取得 卒業論文発表会 繰り返し分の制御に 関連するパターン (アスペクトの候補 とはいい難い) 2007/02/27 Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 14
抽出されたメソッド呼び出しパターンの例 (機能に関連しているパターン) 実行コマンド取り消しのための情 報を保存するためのパターン (アスペクト候補) org. jhotdraw. standard. Send. To. Back. Command コマンド実行 public void execute() { super. execute(); set. Undo. Activity(create. Undo. Activity()); get. Undo. Activity(). set. Affected. Figures(view(). selection. ZOrdered()); Figure. Enumeration fe = get. Undo. Activity(). get. Affected. Figures(); while (fe. has. Next. Figure()) { view(). drawing(). send. To. Back(fe. next. Figure()); } view(). check. Damage(); } 実行コマンド取り消しの ための情報を保存 org. jhotdraw. standard. Paste. Command 実行コマンドの処理 public void execute() { super. execute(); Point last. Click = view(). last. Click(); Figure. Selection selection = (Figure. Selection)Clipboard. get. Clipboard(). get. Conten; if (selection != null) { set. Undo. Activity(create. Undo. Activity()); get. Undo. Activity(). set. Affected. Figures( (Figure. Enumerator)selection. get. Data(Standard. Figure. Selection. TYPE)); if (!get. Undo. Activity(). get. Affected. Figures(). has. Next. Figure()) { set. Undo. Activity(null); return; } 実行コマンドがビューに 与えた影響をチェック Rectangle r = get. Bounds(get. Undo. Activity(). get. Affected. Figures()); view(). clear. Selection(); メソッド呼び出しパターン Abstract. Command. execute() Abstract. Command. set. Undo. Activity() Abstract. Command. get. Undo. Activity() Undoable. set. Affected. Figures() Abstract. Command. get. Undo. Activity() Undoable. get. Affected. Figures() Figure. Enumeration. has. Next. Figure() Abstract. Command. view() Drawing. View. check. Damage() Figure. Enumeration fe = insert. Figures(get. Undo. Activity(). get. Affected. Figures() get. Undo. Activity(). set. Affected. Figures(fe); view(). check. Damage(); } } 卒業論文発表会 実行コマンドがビューに与えた影 響をチェックするためのパターン 2007/02/27 (アスペクト候補) Department of Computer Science, Graduate School of Information Science & Technology, Osaka University 17
- Slides: 18