コマンドを使用して関数を置き換える

refactorgram

  function score(candidate, medicalExam, scoringGuide) {
    let result = 0;
    let healthLevel = 0;
    // long body code
  }

image/svg+xml

class Scorer {
  constructor(candidate, medicalExam, scoringGuide) {
    this._candidate = candidate;
    this._medicalExam = medicalExam;
    this._scoringGuide = scoringGuide;
  }

  execute() {
    this._result = 0;
    this._healthLevel = 0;
    // long body code
  }
}

の逆 関数をコマンドを使用して置き換える

別名 メソッドオブジェクトを使用してメソッドを置き換える