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
79
votes
3 answers

Why should java package name be lowercase?

Actually this is completely theoretic question. But it's interesting why java specification don't allow uppercase characters letters in package and cause write something like…
77
votes
6 answers

What characters are allowed in C# class name?

What characters are allowed and what is not allowed in a C# class name? Could you please help? EDIT: To specify. What special characters are allowed? Please be specific, because links to 50 pages specs in high-technical language is not an answer…
Tom Smykowski
  • 25,487
  • 54
  • 159
  • 236
77
votes
4 answers

CSS class naming convention

On a web page, there are two blocks of controls (primary and secondary), what class names would most people use? Choice 1:
bobo
  • 8,439
  • 11
  • 57
  • 81
77
votes
10 answers

What is a good naming convention for vars, methods, etc in C++?

I come from a the Objective-C and Cocoa world where there are lots of conventions and many people will say it makes your code beautiful! Now programming in C++ I cannot find a good document like this one for…
nacho4d
  • 43,720
  • 45
  • 157
  • 240
77
votes
18 answers

SQL Join Table Naming Convention

I have 2 tables: Users and Roles, and I have a table that joins these together. The only thing in the join table is Ids that link the 2 tables. What should I call this table? I've never really seen a good naming convention for this. Conventions I've…
Josh Close
  • 22,935
  • 13
  • 92
  • 140
76
votes
3 answers

Underscores or camelCase in PostgreSQL identifiers, when the programming language uses camelCase?

Given an OO language in which the naming convention for object properties is camelCased, and an example object like this: { id: 667, firstName: "Vladimir", lastName: "Horowitz", canPlayPiano: true } How should I model this structure…
Zilk
  • 8,917
  • 7
  • 36
  • 44
75
votes
2 answers

Association between naming classes and naming their files in python (convention?)

In python (and some other languages) I have learned, that the name of a class should be written in small letters except for the first letter of each word, which should be a capital letter. Example: class FooBar: ... A class should go in a file,…
Aufwind
  • 25,310
  • 38
  • 109
  • 154
75
votes
5 answers

Naming of boolean column in database table

I have 'Service' table and the following column description as below Is User Verification Required for service ? Is User's Email Activation Required for the service ? Is User's Mobile Activation required for the service ? I Hesitate in naming…
Amr Badawy
  • 7,453
  • 12
  • 49
  • 84
75
votes
4 answers

How do I override rails naming conventions?

I have a model named "clothing" which I want to be the singlular (one piece of clothing). By default, rails says the plural is clothings. Right or wrong, I think it will be more readable if the plural is "clothes". How do I override the plural…
chrishomer
  • 4,900
  • 5
  • 38
  • 52
74
votes
7 answers

Swift: Global constant naming convention?

In Swift, it seems that global constants should be camelCase. For example: let maximumNumberOfLoginAttempts = 10 Is that correct? I'm used to all caps, e.g., MAXIMUM_NUMBER_OF_LOGIN_ATTEMPTS, from C, but I want to acquiesce to Swift conventions.
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
74
votes
17 answers

Best practices for C# GUI naming conventions?

GUIs, whether written in WinForms or XAML, seem to have the most widely differing naming conventions between projects I see. For a simple TextBox for a person's name, I've seen various naming conventions: TextBox tbName // Hungarian…
Will Eddins
  • 13,628
  • 5
  • 51
  • 85
73
votes
10 answers

How to name a HashMap in Java?

This might be a silly question, but I have never found a satisfying way to name a variable of type HashMap in Java. For example - lets say I have a HashMap where every bucket is a pair where K is a String say representing "State" and V is…
user396089
  • 1,115
  • 1
  • 12
  • 26
73
votes
3 answers

Underscore _ as variable name in Python

Peter Norvig has an essay describing a program to solve sudoku puzzles, even the hardest ones, by combining deterministic logical operations and smart traversal of the possible solutions. The latter is done recursively; here's that function…
72
votes
12 answers

Do you name your arrays using plural or singular in PHP?

When I'm naming array-type variables, I often am confronted with a dilemma: Do I name my array using plural or singular? For example, let's say I have an array of names: In PHP I would say: $names=array("Alice","Bobby","Charles"); However, then…
stalepretzel
  • 15,543
  • 22
  • 76
  • 91
71
votes
4 answers

When do I call my class controller, manager or service?

Maybe it is obvious to you. I'm new to java (half year work) and I had a discussion with my collegues. I have troubles naming my classes according to their responsibilities. For that, my classes gain responsibilities they should never have. Can you…
MartinL
  • 3,198
  • 4
  • 18
  • 20