Replace Command with Function

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;
}

inverse of Replace Function with Command