Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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));
}
like image 428
BuddyJoe Avatar asked Sep 09 '10 15:09

BuddyJoe


People also ask

What should be the naming convention for methods?

Methods should be verbs in lowerCamelCase or a multi-word name that begins with a verb in lowercase; that is, with the first letter lowercase and the first letters of subsequent words in uppercase. Local variables, instance variables, and class variables are also written in lowerCamelCase .

What are naming conventions examples?

What is an example of a good naming convention? Good naming examples include: [Project number] - Data Use Agreement - [Title of research project] Approval - Change to employee travel policy - February 2014.

What are naming conventions in programming?

Naming conventions are general rules applied when creating text scripts for software programming. They have many different purposes, such as adding clarity and uniformity to scripts, readability for third-party applications, and functionality in certain languages and applications.

What is the naming convention for Java?

Java variable naming conventions For variables, the Java naming convention is to always start with a lowercase letter and then capitalize the first letter of every subsequent word.


1 Answers

How about updateButtonVisibilty()?

like image 127
Andy Thomas Avatar answered Nov 27 '22 00:11

Andy Thomas