Search code examples
methodsnaming-conventionsnaming

Method Naming Convention Question (most languages)


If I have a method that hides a button, I would probably call it HideButton
If I have a method that shows a button, I would probably call it ShowButton

But what do you guys call a ShowIfThisHideIfThat style method?

Possible Choices:
TestForButtonVisibility (this kind of sounds like it will return true/false but not actually do the work)
TestButton
ShowHideButton (style I'm currently using)

Been at this a number of years and still don't have a style that I like for these types of methods. I'm working mostly in C# and a little Java, Ruby, and F#. What do you use for method names in this regard?

// example of the style of method
public void ShouldIShowOrHideButton()
{
  Button.Visible = ((chkSomeSetting.Checked) && (DateTime.Now.Day < 8));
}

Solution

  • How about updateButtonVisibilty()?