Comment by lscharen
1 day ago
Maybe something (contrived) like this providing no-op defaults?
total = calculateOrderTotal(user.order);
if (user.isPremiumMember) {
total = total * 0.9; // 10% discount
versus
total = calculateOrderTotal(user.order);
discount = calculateDiscount(user); // Returns 0.9 or 1.0
total = total * discount;
Didn't you just shift the branch to the calculateDiscount() function?
Not necessarily.
would also cut it.
OK, or maybe...
Or:
or: