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 } }
反之 用命令替换函数
别名 用方法对象替换方法