247 reputation
26
bio website
location Boulder, CO
age 32
visits member for 4 years, 4 months
seen May 18 at 16:19

Web Developer


Feb
11
comment Is it better to call a function multiple times, or to assign a variable multiple times and call the function once?
I think it depends on the language, the intent of changing the variables as such, and how likely you think you are going to need to change the arg's to the function. Many times, you could easily build a small hash/map object that has each of the conditions you need, keyed to that condition and then just call the variable with the value of the map. It doesn't really slim down the content, but it organizes and reduces the chance that you would miss a function call if you later need to edit the call.