Skip to main content

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
Filter by
Sorted by
Tagged with
1868 votes
19 answers
815k views

What is the meaning of single and double underscore before an object name?

What do single and double leading underscores before an object's name represent in Python?
1857 votes
41 answers
578k views

Table Naming Dilemma: Singular vs. Plural Names [closed]

Academia has it that table names should be the singular of the entity that they store attributes of. I dislike any T-SQL that requires square brackets around names, but I have renamed a Users table ...
1479 votes
12 answers
321k views

Naming Classes - How to avoid calling everything a "<WhatEver>Manager"? [closed]

A long time ago I have read an article (I believe a blog entry) which put me on the "right" track on naming objects: Be very very scrupulous about naming things in your program. For example if my ...
1383 votes
7 answers
811k views

What are some examples of commonly used practices for naming git branches? [closed]

I've been using a local git repository interacting with my group's CVS repository for several months, now. I've made an almost neurotic number of branches, most of which have thankfully merged back ...
skiphoppy's user avatar
  • 101k
1135 votes
16 answers
300k views

Why would a JavaScript variable start with a dollar sign? [duplicate]

I quite often see JavaScript with variables that start with a dollar sign. When/why would you choose to prefix a variable in this way? (I'm not asking about $('p.foo') syntax that you see in jQuery ...
Ken's user avatar
  • 78.3k
1095 votes
16 answers
833k views

What is the naming convention in Python for variables and functions?

Coming from a C# background the naming convention for variables and methods are usually either camelCase or PascalCase: // C# example string thisIsMyVariable = "a" public void ThisIsMyMethod(...
Ray's user avatar
  • 190k
1066 votes
6 answers
348k views

What are the rules about using an underscore in a C++ identifier?

It's common in C++ to name member variables with some kind of prefix to denote the fact that they're member variables, rather than local variables or parameters. If you've come from an MFC background, ...
Roger Lipscombe's user avatar
923 votes
23 answers
732k views

Database, Table and Column Naming Conventions? [closed]

Whenever I design a database, I always wonder if there is a best way of naming an item in my database. Quite often I ask myself the following questions: Should table names be plural? Should column ...
GateKiller's user avatar
  • 75.3k
829 votes
27 answers
364k views

Should I use Singular or Plural name convention for REST resources?

Some RESTful services use different resource URIs for update/get/delete and Create. Such as Create - using /resources with POST method (observe plural) at some places using /resource (singular) ...
JPReddy's user avatar
  • 64.8k
796 votes
5 answers
445k views

What is the purpose of the single underscore "_" variable in Python?

What is the meaning of _ after for in this code? if tbh.bag: n = 0 for _ in tbh.bag.atom_set(): n += 1
alwbtc's user avatar
  • 29.1k
743 votes
4 answers
52k views

Why aren't ◎ܫ◎ and ☺ valid JavaScript variable names?

I noticed that in Internet Explorer (but, unfortunately, not in the other browsers I tested), you can use some Unicode variable names. This made my day, and I was absolutely delighted that I could ...
Peter Olson's user avatar
701 votes
15 answers
251k views

What's the name for hyphen-separated case?

This is PascalCase: SomeSymbol This is camelCase: someSymbol This is snake_case: some_symbol So my questions is whether there is a widely accepted name for this: some-symbol? It's commonly used in ...
lmirosevic's user avatar
  • 16.1k
665 votes
13 answers
195k views

Why are exclamation marks used in Ruby methods?

In Ruby some methods have a question mark (?) that ask a question like include? that ask if the object in question is included, this then returns a true/false. But why do some methods have ...
Lennie's user avatar
  • 10.8k
646 votes
11 answers
521k views

Unit test naming best practices [closed]

What are the best practices for naming unit test classes and test methods? This was discussed on SO before, at What are some popular naming conventions for Unit Tests? I don't know if this is a very ...
James Newton-King's user avatar
580 votes
6 answers
411k views

Is there a naming convention for git repositories?

For example, I have a RESTful service called Purchase Service. Should I name my repository: purchaserestservice purchase-rest-service purchase_rest_service or something else? What's the convention? ...
Adrian M's user avatar
  • 7,397
558 votes
9 answers
356k views

C# naming convention for constants?

private const int THE_ANSWER = 42; or private const int theAnswer = 42; Personally I think with modern IDEs we should go with camelCase as ALL_CAPS looks strange. What do you think?
mmiika's user avatar
  • 10.2k
544 votes
6 answers
262k views

What is the convention for word separator in Java package names?

How should one separate words in package names? Which of the following are correct? com.stackoverflow.my_package (Snake Case using underscore) com.stackoverflow.my-package (Kebab Case using hyphens) ...
Jigar's user avatar
  • 9,271
543 votes
5 answers
225k views

Is it .yaml or .yml?

According to yaml.org, the official file extension is .yaml. Quote: Is there an official extension for YAML files? Please use ".yaml" when possible. However there seems to be a ...
spuder's user avatar
  • 18k
470 votes
12 answers
529k views

What is the purpose of the dollar sign in JavaScript?

The code in question is here: var $item = $(this).parent().parent().find('input'); What is the purpose of the dollar sign in the variable name, why not just exclude it?
Keith's user avatar
  • 26.4k
419 votes
9 answers
323k views

Java Interfaces/Implementation naming convention [duplicate]

How do you name different classes / interfaces you create? Sometimes I don't have implementation information to add to the implementation name - like interface FileHandler and class SqlFileHandler. ...
Amir Rachum's user avatar
  • 78.6k
384 votes
3 answers
361k views

Should I use "camel case" or underscores in Python? [duplicate]

So which is better and why? def my_function(): or def myFunction():
tdc's user avatar
  • 8,437
375 votes
5 answers
285k views

What is the javascript filename naming convention?

Should files be named something-with-hyphens.js, camelCased.js, or something else? I didn't find the answer to this question here.
ripper234's user avatar
  • 228k
372 votes
11 answers
261k views

Interface naming in Java [closed]

Most OO languages prefix their interface names with a capital I, why does Java not do this? What was the rationale for not following this convention? To demonstrate what I mean, if I wanted to have ...
Allain Lalonde's user avatar
361 votes
10 answers
253k views

Enum Naming Convention - Plural

I'm asking this question despite having read similar but not exactly what I want at C# naming convention for enum and matching property I found I have a tendency to name enums in plural and then 'use'...
o.k.w's user avatar
  • 25.7k
360 votes
5 answers
382k views

Maven artifact and groupId naming

I'm currently in the process of moving some project from Ant to Maven. Conformist as I am, I want to use well-established conventions for finding groupId and artifactId, but I can't find any detailed ...
Noarth's user avatar
  • 4,071
356 votes
11 answers
141k views

What does a type followed by _t (underscore-t) represent?

This seems like a simple question, but I can't find it with the Stack Overflow search or Google. What does a type followed by a _t mean? Such as int_t anInt; I see it a lot in C code meant to deal ...
Kevin Griffin's user avatar
350 votes
2 answers
279k views

What is the difference between .yaml and .yml extension? [duplicate]

I read them on YAML-wikipedia but not really understood the main difference between them. I saw there are someone using .yaml extension, however, Symfony2 use .yml extension. YAML is a human-...
lvarayut's user avatar
  • 14.8k
336 votes
7 answers
303k views

Coding Conventions - Naming Enums

Is there a convention for naming enumerations in Java? My preference is that an enum is a type. So, for instance, you have an enum Fruit{Apple,Orange,Banana,Pear, ... } NetworkConnectionType{LAN,...
318 votes
3 answers
259k views

PostgreSQL naming conventions

Where can I find a detailed manual about PostgreSQL naming conventions? (table names vs. camel case, sequences, primary keys, constraints, indexes, etc...)
boj's user avatar
  • 11.2k
311 votes
11 answers
244k views

How to name Dockerfiles

I'm unsure of how to name Dockerfiles. Many on GitHub use Dockerfile without a file extension. Do I give them a name and extension; if so what? Or do I just call them Dockerfile?
Lloyd R. Prentice's user avatar
302 votes
9 answers
98k views

Correct Bash and shell script variable capitalization [closed]

I run across many shell scripts with variables in all caps, and I've always thought that there is a severe misunderstanding with that. My understanding is that, by convention (and perhaps by ...
JasonSmith's user avatar
  • 73.4k
295 votes
42 answers
60k views

Anyone else find naming classes and methods one of the most difficult parts in programming? [closed]

So I'm working on this class that's supposed to request help documentation from a vendor through a web service. I try to name it DocumentRetriever, VendorDocRequester, DocGetter, but they just don't ...
294 votes
6 answers
258k views

Is the underscore prefix for property and method names merely a convention?

Is the underscore prefix in JavaScript only a convention, like for example in Python private class methods are? From the 2.7 Python documentation: “Private” instance variables that cannot be ...
Kenny Meyer's user avatar
  • 7,947
294 votes
6 answers
225k views

What are naming conventions for MongoDB?

Is there a set of preferred naming conventions for MongoDB entitites such as databases, collections, field names? I was thinking along these lines: Databases: consist of the purpose (word in ...
Andrey's user avatar
  • 21k
290 votes
5 answers
132k views

Redis key naming conventions? [closed]

What is the standard naming convention for keys in redis? I've seen values separated by :, but I'm not sure what the standard convention is. For a user, would you do something like:user:00 If the user'...
fancy's user avatar
  • 50.6k
285 votes
11 answers
88k views

Should a "static final Logger" be declared in UPPER-CASE?

In Java, static final variables are constants and the convention is that they should be in upper-case. However, I have seen that most people declare loggers in lower-case which comes up as a violation ...
dogbane's user avatar
  • 272k
277 votes
8 answers
99k views

Why do variable names often start with the letter 'm'? [duplicate]

Looking at the Android tutorials such as the Notepad tutorial, I noticed that almost all variables are named starting with the letter 'm'. What convention is this, and where does it originate from?
Kallja's user avatar
  • 5,442
275 votes
2 answers
72k views

What is the etymology of 'slug' in a URL? [closed]

Is "URL slug" a completely arbitrary word? Or does it stand for something? I used the word in a conversation with someone and when they asked me why it's called that I realized I didn't know....
Matthew's user avatar
  • 15.5k
274 votes
10 answers
109k views

Java Naming Convention with Acronyms [closed]

What is the correct name for the following Java class: DVDPlayer or DvdPlayer?
DD.'s user avatar
  • 21.8k
272 votes
13 answers
94k views

Why is the asterisk before the variable name, rather than after the type?

Why do most C programmers name variables like this: int *myVariable; rather than like this: int* myVariable; Both are valid. It seems to me that the asterisk is a part of the type, not a part of ...
WBlasko's user avatar
  • 3,023
262 votes
6 answers
176k views

JavaScript naming conventions [closed]

I know there is a lot of controversy (maybe not controversy, but arguments at least) about which naming convention is the best for JavaScript. How do you name your variables, functions, objects and ...
peirix's user avatar
  • 37.4k
262 votes
11 answers
154k views

Should you use .htm or .html file extension? What is the difference, and which file is correct? [closed]

What is the difference between the .htm and .html file extension? Why there are two of them? Which is correct?
244 votes
11 answers
281k views

For a boolean field, what is the naming convention for its getter/setter?

Eg. boolean isCurrent = false; What do you name its getter and setter?
user496949's user avatar
  • 85.2k
244 votes
8 answers
90k views

Why are dashes preferred for CSS selectors / HTML attributes?

In the past I've always used underscores for defining class and id attributes in HTML. Over the last few years I changed over to dashes, mostly to align myself with the trend in the community, not ...
Andrew Vit's user avatar
  • 19.1k
243 votes
2 answers
56k views

Naming of enums in Java: Singular or Plural?

Is there an "official" recommendation of how to name Java enums? enum Protocol { HTTP, HTTPS, FTP } or enum Protocols { HTTP, HTTPS, FTP } I know in the .Net world the recommendation is to use ...
friederbluemle's user avatar
237 votes
18 answers
128k views

URLs: Dash vs. Underscore [closed]

Is it better convention to use hyphens or underscores in your URLs? Should it be /about_us or /about-us? From usability point of view, I personally think /about-us is much better for end-user yet ...
232 votes
76 answers
17k views

What's the best name for a non-mutating "add" method on an immutable collection? [closed]

Sorry for the waffly title - if I could come up with a concise title, I wouldn't have to ask the question. Suppose I have an immutable list type. It has an operation Foo(x) which returns a new ...
232 votes
7 answers
173k views

Are there best practices for (Java) package organization? [closed]

A little while ago, I saw a question answered here regarding the fine-grained organization of Java packages. For example, my.project.util, my.project.factory, my.project.service, etc. Are there best ...
Cyntech's user avatar
  • 5,532
232 votes
4 answers
145k views

SQL Server Index Naming Conventions [closed]

Is there some standard way to name indexes for SQL Server? It seems that the primary key index is named PK_ and non-clustered indexes typically start with IX_. Are there any naming conventions ...
Eric Ness's user avatar
  • 10.3k
223 votes
10 answers
205k views

Are there any naming convention guidelines for REST APIs? [closed]

When creating REST APIs, are there any guidelines or defacto standards for naming conventions within the API (eg: URL endpoint path components, querystring parameters)? Are camel caps the norm, or ...
jnorris's user avatar
  • 6,470

1
2 3 4 5
81