用函数替换命令

refactorgram

class ChargeCalculator {
  constructor (customer, usage){
    this._customer = customer;
    this._usage = usage;
  }
  execute() {
    return this._customer.rate * this._usage;
  }
}

image/svg+xml

function charge(customer, usage) {
  return customer.rate * usage;
}

相反的 用函数替换命令