I agree with calculating only once using a method and storing the value because calling the same method 2 or 3 times is too much (especially for a calculation method that might make a call to the database calling a stored procedure or calculates based on complex business rules).
Extracting the method and calling 2 or 3 times made an optimized code less performant just for the sake of extracting a method without leaving the temp variable. Making queries all the time makes the code less performant every time, there's no doubt that this refactoring doesn't make the code cleaner or more optimized (the code is not cleaner, only that 1 line that optimized code was removed).
I also do not agree with the "optimize later" statement especially when you see the optimization problem beforehand because you can forget about the optimization by mistake and leave bad code.
I agree with calculating only once using a method and storing the value because calling the same method 2 or 3 times is too much (especially for a calculation method that might make a call to the database calling a stored procedure or calculates based on complex business rules).
Extracting the method and calling 2 or 3 times made an optimized code less performant just for the sake of extracting a method without leaving the temp variable. Making queries all the time makes the code less performant every time, there's no doubt that this refactoring doesn't make the code cleaner or more optimized (the code is not cleaner, only that 1 line that optimized code was removed).
I also do not agree with the "optimize later" statement especially when you see the optimization problem beforehand because you can forget about the optimization by mistake and leave bad code.