From time to time I write a function that just creates something if it's not there yet and otherwise does nothing.
Names like CreateFooIfNecessary() or EnsureThereIsAFoo() do work but they feel a bit clumsy.
One could also say GetFoo() but that name doesn't really imply that foo may be created first and it only works if the function returns a handle/pointer/reference to foo.
Can those of you more familiar with the English language come up with a better way to name these functions?
How about GetOrCreate()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With