function score(candidate, medicalExam, scoringGuide) { let result = 0; let healthLevel = 0; // long body code }
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 } }
用函數取代命令 的反向操作
別名 用方法物件取代方法