I often need to use a function which performs and action X is condition Y is set. What is the best way to name such a function?
I don't want to repeat if statements, since they could be complex.
For instance, if I want to trim a string if a property is set, function could be named:
- void TrimIfOptionSet(string) -- too unwieldy, especially if condition is complex
- bool TryTrim(string) -- does not mention an external condition, I'd expect it to only take the argument into account.
- void ConditionalTrim(string) -- bit verbose
Are there any conventions for this situation in C#/.Net, or any similar language?