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
1793
votes
18 answers

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?
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
1790
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
  • 49,207
  • 121
  • 399
  • 775
1464
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,190
  • 6
  • 30
  • 42
1355
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
  • 97,646
  • 72
  • 174
  • 218
1125
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
  • 77,016
  • 30
  • 84
  • 101
1049
votes
15 answers

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() In Python, I have seen the above but I have also seen…
Ray
  • 187,153
  • 97
  • 222
  • 204
1045
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
  • 89,048
  • 55
  • 235
  • 380
907
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
  • 74,180
  • 73
  • 171
  • 204
787
votes
27 answers

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) Update - using /resource/123 with PUT method Get -…
JPReddy
  • 63,233
  • 16
  • 64
  • 93
778
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
  • 28,057
  • 62
  • 134
  • 188
743
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
  • 139,199
  • 49
  • 202
  • 242
671
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.
lmirosevic
  • 15,787
  • 13
  • 70
  • 116
653
votes
12 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
  • 10,605
  • 5
  • 22
  • 13
647
votes
11 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
  • 48,174
  • 24
  • 109
  • 130
547
votes
6 answers

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? How about in GitHub? Should public repositories…
Adrian M
  • 7,047
  • 7
  • 24
  • 26
1
2 3
99 100