I was wondering about which type of code should I write:
public BigDecimal getItemSubTotal(BigDecimal quantity) {
return getBasePrice().multiply(quantity).multiply(getRentalAdjustment()).add(getOtherAdjustments());
}
OR
public BigDecimal getItemSubTotal(BigDecimal quantity) {
BigDecimal basePrice = getBasePrice();
BigDecimal rentalAdj = getRentalAdjustment();
BigDecimal otherAdj = getOtherAdjustments();
return basePrice.multiply(quantity).multiply(rentalAdj).add(otherAdj);
}
Which code block is better apart from code readability & why? Which code block will take less time & memory?