Questions tagged [naming-conventions]

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

Existing Questions about Naming Conventions

3872 questions
1578
votes
41 answers

Table Naming Dilemma: Singular vs. Plural Names

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 to the singular, forever sentencing those using…
ProfK
  • 44,292
  • 106
  • 358
  • 713
1442
votes
17 answers

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

Can someone please explain the exact meaning of having single and double leading underscores before an object's name in Python, and the difference between both? Also, does that meaning stay the same regardless of whether the object in question is a…
Ram Rachum
  • 71,442
  • 73
  • 210
  • 338
1290
votes
12 answers

Naming Classes - How to avoid calling everything a "Manager"?

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 application was (as a typical business app) handling…
froh42
  • 5,040
  • 6
  • 28
  • 42
1215
votes
7 answers

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

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 into my trunk. But naming is starting to become…
skiphoppy
  • 83,104
  • 64
  • 169
  • 214
1074
votes
16 answers

Why would a JavaScript variable start with a dollar sign?

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 and others, but normal variables like $name and…
Ken
  • 71,088
  • 29
  • 81
  • 100
969
votes
5 answers

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, you'll probably use m_foo. I've also seen myFoo…
Roger Lipscombe
  • 81,986
  • 49
  • 214
  • 348
852
votes
13 answers

What is the naming convention in Python for variable and function names?

Coming from a C# background the naming convention for variables and method names are usually either camelCase or PascalCase: // C# example string thisIsMyVariable = "a" public void ThisIsMyMethod() In Python, I have seen the above but I have also…
Ray
  • 169,974
  • 95
  • 213
  • 200
815
votes
23 answers

Database, Table and Column Naming Conventions?

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 names be singular? Should I prefix tables or…
GateKiller
  • 68,419
  • 71
  • 167
  • 203
733
votes
4 answers

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 write fun Unicode-laden code like this: var…
Peter Olson
  • 121,487
  • 47
  • 188
  • 235
669
votes
5 answers

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
  • 23,407
  • 50
  • 123
  • 177
617
votes
12 answers

Unit test naming best practices

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 good approach, but currently in my testing…
James Newton-King
  • 44,416
  • 22
  • 106
  • 128
606
votes
22 answers

REST URI convention - Singular or plural name of resource while creating it

I'm new to REST and I've observed that in some RESTful services they use different resource URI for update/get/delete and Create. Such as Create - using /resources with POST method (observe plural) at some places using /resource (singular) Update -…
JPReddy
  • 56,119
  • 15
  • 60
  • 93
572
votes
10 answers

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 exclamation marks (!) where others don't? What does it mean?
Lennie
  • 9,525
  • 5
  • 20
  • 13
563
votes
15 answers

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 url's.
lms
  • 14,269
  • 12
  • 64
  • 113
459
votes
9 answers

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
  • 8,992
  • 5
  • 26
  • 34
1
2 3
99 100