The code should be easy to read, quick to understand, and quick to change.
Better than time-bound comments are clear variable names, although they are good for a general description of the cause. Name constant (i.e. What is 0.04 + 0.2 ?) And expressions for brevity in context (also avoids unnecessary function calls).
// Estimate process time const infoFetched = this._isFetched('studentInfoFetched') const infoFetchTime = 0.04 + 0.2 const canExpire = formInputValues.student_expiration const expirationFetched = this._isFetched('studentExpirationFetched') const expirationFetchTime = 14 if (!infoFetched) tempAddedTime += 1 if (hasExpired && !expirationFetched) tempAddedTime += expirationFetchTime if (!infoFetched) estimatedTimePerStudent += fetchTime if (hasExpired) estimatedTimePerStudent += 1
I usually like to multiply booleans as switches, although in this case, if may be a little easier to read, understand, and modify;
tempAddedTime += !infoFetched* 1 + (hasExpired && !expirationFetched)* expirationFetchTime estimatedTimePerStudent += !infoFetched* fetchTime + hasExpired* 1
Not the best example is likely to be completely different if I had access / knowledge of what he did for this / source
source share