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

URLs: Dash vs. Underscore

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 Google and most other websites (and javascript…
lubos hasko
  • 24,752
  • 10
  • 56
  • 61
229
votes
4 answers

SQL Server Index Naming Conventions

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 beyond that for unique indexes?
Eric Ness
  • 10,119
  • 15
  • 48
  • 51
227
votes
7 answers

Are there best practices for (Java) package organization?

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 practices with regards to the organization of…
Cyntech
  • 5,362
  • 6
  • 33
  • 47
221
votes
10 answers

Are there any naming convention guidelines for REST APIs?

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 underscores? others? For…
jnorris
  • 6,350
  • 8
  • 30
  • 33
208
votes
7 answers

What are some popular naming conventions for Unit Tests?

General Follow the same standards for all tests. Be clear about what each test state is. Be specific about the expected behavior. Examples 1) MethodName_StateUnderTest_ExpectedBehavior Public void Sum_NegativeNumberAs1stParam_ExceptionThrown()…
stung
  • 347
  • 5
  • 13
  • 27
207
votes
6 answers

When is "Try" supposed to be used in C# method names?

We were discussing with our coworkers on what it means if the method name starts with "Try". There were the following opinions: Use "Try" when the method can return a null value. Use "Try" when the method will not throw an exception. What is the…
ms007
  • 4,661
  • 3
  • 28
  • 31
206
votes
6 answers

What does iota of std::iota stand for?

I'm assuming the "i" is increment and the "a" is assign, but I could not figure out or find the answer. Also, it looks very similar to the non-standard itoa which I think is confusing.
Jesse Good
  • 50,901
  • 14
  • 124
  • 166
204
votes
8 answers

Node.js project naming conventions for files & folders

What are the naming conventions for files and folders in a large Node.js project? Should I capitalize, camelCase, or under-score? Ie. is this considered valid? project-name app controllers someThings.js users.js …
Rudiger
  • 6,634
  • 9
  • 40
  • 57
203
votes
10 answers

count vs length vs size in a collection

From using a number of programming languages and libraries I have noticed various terms used for the total number of elements in a collection. The most common seem to be length, count, and size. eg. array.length vector.size() collection.count Is…
molasses
  • 3,258
  • 6
  • 22
  • 22
202
votes
7 answers

Is there a naming convention for MySQL?

Here's how I do it: Table names are lower case, uses underscores to separate words, and are singular (e.g. foo, foo_bar, etc. I generally (not always) have a auto increment PK. I use the following convention: tablename_id (e.g. foo_id, foo_bar_id,…
StackOverflowNewbie
  • 39,403
  • 111
  • 277
  • 441
202
votes
13 answers

What are the most common naming conventions in C?

What are the naming conventions commonly use in C? I know there are at least two: GNU / linux / K&R with lower_case_functions ? name ? with UpperCaseFoo functions I am talking about C only here. Most of our projects are small embedded systems in…
JeffV
  • 52,985
  • 32
  • 103
  • 124
195
votes
3 answers

Go naming conventions for const

I'm trying to determine whether there is a naming convention for the names of const in Golang. I personally would tend to follow the C style and write them in upper case, but I haven't found anything on this page…
LtWorf
  • 7,286
  • 6
  • 31
  • 45
194
votes
12 answers

Naming conventions: "State" versus "Status"

Quick question: I'd like to hear your thoughts on when to use "State" versus "Status" when naming both fields such as "Foo.currentState" vs "Foo.status" and types, like "enum FooState" vs "enum FooStatus". Is there a convention discussed out there?…
Sophistifunk
  • 4,742
  • 4
  • 28
  • 37
189
votes
5 answers

Relational table naming convention

I'm starting a new project and would like to get my table and column names right. For example I've always used plural in table names but recently learned singular is correct. So if I have a table user and I have products that only the user will…
189
votes
10 answers

Foreign Key naming scheme

I'm just getting started working with foreign keys for the first time and I'm wondering if there's a standard naming scheme to use for them? Given these tables: task (id, userid, title) note (id, taskid, userid, note); user (id, name) Where Tasks…
nickf
  • 537,072
  • 198
  • 649
  • 721