What is a good way to name a method that checks if X needs to be done, and does X it if necessary?
For example, how to name a method that updates a user list if new users have logged in? UpdateListIfNeeded
seems too long, while simple UpdateList
implies a possibly expensive and unnecessary operation is done every time. EnsureListUpdated
is a variant as well.
C# has a bool TryXXX(args, out result)
pattern (e.g. int.TryParse(str, out num)
) to check if X is possible and do it, but that is subtly different.
RefreshUserList()
duringLoginUser()
andLogoutUser()
, and not during, sayGetUser()
(where the list should be up-to-date already), then by all means the advice below applies.