Questions tagged [naming-conventions]

Do not use this tag to ask what you should name something. Naming conventions refer to general rules governing names assigned to programming constructs such as variables and methods. These conventions facilitate readability, and thus improved maintainability of code by enforcing naming consistency across disparate modules.

Naming conventions refer to general rules governing names assigned to programming constructs such as variables and methods. These conventions facilitate readability, and thus improved maintainability of code by enforcing naming consistency across disparate modules.

Examples

4026 questions
121
votes
9 answers

What is your preferred style for naming variables in R?

Which conventions for naming variables and functions do you favor in R code? As far as I can tell, there are several different conventions, all of which coexist in cacophonous harmony: 1. Use of period separator, e.g. stock.prices <- c(12.01,…
medriscoll
  • 26,995
  • 17
  • 40
  • 36
119
votes
2 answers

Where did the name `atoi` come from?

In the C language where did they come up with the name atoi for converting a string to an integer? The only thing I can think of is Array To Integer for an acronym but that doesn't really make sense.
Earlz
  • 62,085
  • 98
  • 303
  • 499
119
votes
4 answers

ASP.NET MVC Controller Naming Pluralization

RESTful conventions indicate using plural nouns over singular objects. What is the pluralization convention for naming ASP.NET MVC controllers, i.e. ProductController or ProductsController?
115
votes
9 answers

Singular or plural controller and helper names in Rails

Is there any disadvantage to using singular names for controllers and helpers? Nothing seems to rely on this. It even seems helpers don't have to make the same choice about singular vs. plural as their corresponding controllers, at least according…
allyourcode
  • 21,871
  • 18
  • 78
  • 106
114
votes
7 answers

Naming conventions for Java methods that return boolean

I like using question mark at the end of method/function names in other languages. Java doesn't let me do this. As a workaround how else can I name boolean returning methods in Java? Using an is, has, should, can in the front of a method sound okay…
letronje
  • 9,002
  • 9
  • 45
  • 53
114
votes
28 answers

GB English, or US English?

If you have an API, and you are a UK-based developer with a highly international audience, should your API be setColour() or setColor() (To take one word as a simple example.) UK-based engineers are often quite defensive about their 'correct'…
izb
  • 50,101
  • 39
  • 117
  • 168
113
votes
6 answers

Naming conventions for abstract classes

I distinctly remember that, at one time, the guideline pushed by Microsoft was to add the "Base" suffix to an abstract class to obviate the fact that it was abstract. Hence, we have classes like System.Web.Hosting.VirtualFileBase,…
Mike Hofer
  • 16,477
  • 11
  • 74
  • 110
113
votes
2 answers

Naming Conventions For Partial Class Files

I'm generating the bulk of my ASP.NET MVC scaffolding code. All generated files are partial classes which use standard naming conventions. For example, my employee controller file is named EmployeeController.cs. If I wish to extend the…
Ben Griswold
  • 17,793
  • 14
  • 58
  • 60
112
votes
4 answers

Which way to name a function in Go, CamelCase or Semi-CamelCase?

I want to write a function in Go to insert a document into a collection in a MongoDB database. Which way to name the function is better, writeToMongoDB or WriteToMongoD? The second is CamelCase, while I saw someone using the style of the first…
Tim
  • 1
  • 141
  • 372
  • 590
112
votes
8 answers

C# naming conventions for acronyms

Regarding C# naming for acronyms, if I was writing a library related to the Windows API is there any strong convention toward either WindowsApi or WindowsAPI or is it just personal preference?
deltanovember
  • 42,611
  • 64
  • 162
  • 244
111
votes
15 answers

"ID" or "Id" on User Interface

The QA manager where I work just informed me there is a bug in my desktop app due to the sign-on prompt being "Operator Id" when it should be "Operator ID". Her argument being that "Id" refers to the ego portion of Freud's "psychic apparatus" and is…
sipsorcery
  • 30,273
  • 24
  • 104
  • 155
110
votes
6 answers

Standard conventions for indicating a function argument is unused in JavaScript

Are there any standard ways of marking a function argument as unused in JavaScript, analogous to starting a method argument with an underscore in Ruby?
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
109
votes
15 answers

Are there conventions on how to name resources?

Are there conventions how to name resources in Android? For example, buttons, textViews, menus, etc.
Eugene
  • 59,186
  • 91
  • 226
  • 333
109
votes
2 answers

How to build executable with name other than Golang package

Is it possible to build (install, go get, etc) an executable with the name foobar if my Golang package name is one of the following: github.com/username/go-foobar github.com/username/foobar-tools and has main.go in the package root?
Petr Razumov
  • 1,952
  • 2
  • 17
  • 32
108
votes
3 answers

Naming convention for Scala constants?

What is the naming convention for Scala constants? A brief search on StackOverflow suggestions uppercase CamelCase (the first line below), but I wanted to double-check. val ThisIsAConstant = 1.23 val THIS_IS_ANOTHER_CONSTANT = 1.55 val…
grautur
  • 29,955
  • 34
  • 93
  • 128