Let's try to be more general; after all, requiring that some function or other be executed only once isn't that outlandish, and may be required elsewhere! Let's lay down some principles:
- The original function (the one that may be called only once) should do whatever it is expected to do and nothing else.
- We don't want to modify the original function in any way.
- We need to have a new function that will call the original one only once.
- We want a general solution that we can apply to any number of original functions.
The first principle listed previously is the single responsibility principle (the S in S.O.L.I.D.), which states that every function should be responsible for a single functionality. For more on S.O.L.I.D., check the article by Uncle Bob (Robert C. Martin, who wrote the five principles) at http://butunclebob...