lesson 5.
Lesson learned:
Calculate less. Calculate once ( if possible)
Why
Every calculating takes resources ( time, memory, electricity( there are some else?))
Howto
Say, you need use today's date. Indeed there is a function t get it. ( NOW() at T-SQL) instead of calling it over and over again calculate once, put to variable, use the variable. Yes the variable will not change but it will save resources
How I learned
Code review by my team lead.
Best way to jump from "code works" level to "well-written code" :)