Upgrade to Pro — share decks privately, control downloads, hide ads and more …

コードの静的解析ツールを使う目的と効用

Avatar for hihats hihats
August 28, 2017

 コードの静的解析ツールを使う目的と効用

最近の解析ツールはソースコードのスコアリングもしてくれますが、それってどういう基準なの?
というお話をしました。

Avatar for hihats

hihats

August 28, 2017
Tweet

More Decks by hihats

Other Decks in Technology

Transcript

  1. 凝集度 Cohesion 各モジュール内の関連性を最大に すること class A { int width; Int

    height; function widen(int add){ width = width + add; } function highten(int add){ height = height + add; } } クラスのメンバ変数 は2つ 2つのメソッドで使 われているメンバ 変数はそれぞれ ひとつずつ
  2. 凝集度 Cohesion 各モジュール内の関連性を最大に すること class A { int width; Int

    height; function widen(int add){ width = width + add; } function highten(int add){ height = height + add; } } クラスのメンバ変数 は2つ 2つのメソッドで使 われているメンバ 変数はそれぞれ ひとつずつ 凝集度はそれほど 高くない
  3. 結合度 Coupling モジュール間の関連性を最小にす ること class Square { require Rhombus; function

    square(rhombus = new Rhombus){ return rhombus->width * rhombus->width; } } 属性は ・width ・angle があるが、angle がSquareの計算 に必要かというと 必要ない
  4. 結合度 Coupling モジュール間の関連性を最小にす ること class Square { function square(rhombus_width){ return

    rhombus_width * rhombus_width; } } 属性は ・width ・angle があるが、angle がSquareの計算 に必要かというと 必要ない 結合度が下がった!
  5. ifやforを使うと1ずつ増えていく foreach ($array as $key => $value ){ for ($i+0;

    $i< $max; $++){ switch($value[$i]){ case 1: If ($value…) …… 分岐がなければ1(Best値) function good_method($array){ return array_map(function($n) { return $n * $n; }, $array); }