OK. I’m back with another implementation question. This has to do with using a dictionary to branch rather than if/then/else.
Are there instances where one is better than the other like in speed or code space? I am specifically using dictionary/switch codes to call other routines based on certain conditions.
It would seem that if/then
is good if there are not too many (?) needed. Also, it seems if code can (or is desired to) be executed within the if/then
construct, if/then seems to have the advantage since it’s not clear to me that can be done from within a dictionary structure.
From the little I’ve read, it seems a dictionary is more efficient in its execution (don’t know about the amount of memory required, tho). However, if there is code to be executed, a call must be made to another procedure or function (if I understand it correctly) containing that code. I’m not sure if that makes the code more clean or more complicated to sort thru.
I’d welcome some insight and feedback on this from those much more experienced and enlightened than I Thx.