22-degrees
Well-known member
I was reading the responses at this thread and it reminded me of something I, a rookie, see quite often during searches for solutions.
Is it better to save time by writing the easy-to-implement solution to a problem or is it better to aim for the most efficient use of code possible?
Take the example from the linked thread. OP wanted to run a sub, twice per day, at 2 specific times.
The solutions suggested were:
(a) Use a 1 minute interval timer to check if the current time is equal to the required times and run the sub if yes.
(b) Use a timer with it's interval set to the exact amount of time until the action needs to be performed.
A solution to option (b) was presented but it looked like it took longer to create than the solution to option (a) would.
My question. While it may be good practice to aim for the most efficient use of code, where do you, if ever, draw the line? In my opinion, using option (a) in this instance was a quick and simple solution as 1 tick of a 'simple' timer does not stress the processor. But why does everyone push for option (b) style solutions for simple problems such as the one given in this post?
I think my time is worth a lot more than my processors, so when I can, I will utilize its ability in order to increase what I can do with mine.
Is it better to save time by writing the easy-to-implement solution to a problem or is it better to aim for the most efficient use of code possible?
Take the example from the linked thread. OP wanted to run a sub, twice per day, at 2 specific times.
The solutions suggested were:
(a) Use a 1 minute interval timer to check if the current time is equal to the required times and run the sub if yes.
(b) Use a timer with it's interval set to the exact amount of time until the action needs to be performed.
A solution to option (b) was presented but it looked like it took longer to create than the solution to option (a) would.
My question. While it may be good practice to aim for the most efficient use of code, where do you, if ever, draw the line? In my opinion, using option (a) in this instance was a quick and simple solution as 1 tick of a 'simple' timer does not stress the processor. But why does everyone push for option (b) style solutions for simple problems such as the one given in this post?
I think my time is worth a lot more than my processors, so when I can, I will utilize its ability in order to increase what I can do with mine.