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
538
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
  • 9,970
  • 5
  • 28
  • 34
514
votes
6 answers

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) com.stackoverflow.myPackage (Camel…
Jigar
  • 8,762
  • 6
  • 25
  • 26
462
votes
12 answers

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 Donegan
  • 26,213
  • 34
  • 94
  • 129
410
votes
9 answers

Java Interfaces/Implementation naming convention

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. When this happens I usually name the interface in…
Amir Rachum
  • 76,817
  • 74
  • 166
  • 248
372
votes
3 answers

Should I use "camel case" or underscores in Python?

So which is better and why? def my_function(): or def myFunction():
tdc
  • 8,219
  • 11
  • 41
  • 63
367
votes
11 answers

Interface naming in Java

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 a User interface and a User implementation I'd…
Allain Lalonde
  • 91,574
  • 70
  • 187
  • 238
364
votes
5 answers

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
  • 222,824
  • 274
  • 634
  • 905
351
votes
4 answers

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 conventions (there are some, but they don't cover…
Noarth
  • 3,981
  • 6
  • 23
  • 16
350
votes
10 answers

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' them as singular, example: public enum…
o.k.w
  • 25,490
  • 6
  • 66
  • 63
341
votes
10 answers

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 closely with hardware—I can't help but think that…
Kevin Griffin
  • 14,084
  • 7
  • 28
  • 23
328
votes
7 answers

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,Data_3g,Data_4g, ... } I am opposed to naming…
Walter White
296
votes
2 answers

What is the difference between .yaml and .yml extension?

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-readable data serialization format that takes concepts…
lvarayut
  • 13,963
  • 17
  • 63
  • 87
295
votes
3 answers

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
  • 10,935
  • 5
  • 38
  • 57
294
votes
42 answers

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

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 sound right. I ended up browsing through…
Haoest
  • 13,610
  • 29
  • 89
  • 105
291
votes
9 answers

Correct Bash and shell script variable capitalization

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 necessity long ago), environment variables are in…
JasonSmith
  • 72,674
  • 22
  • 123
  • 149