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
188
votes
10 answers

How to name factory like methods?

I guess that most factory-like methods start with create. But why are they called "create"? Why not "make", "produce", "build", "generate" or something else? Is it only a matter of taste? A convention? Or is there a special meaning in…
deamon
  • 89,107
  • 111
  • 320
  • 448
188
votes
19 answers

Naming convention - underscore in C++ and C# variables

It's common to see a _var variable name in a class field. What does the underscore mean? Is there a reference for all these special naming conventions?
Stan
  • 37,207
  • 50
  • 124
  • 185
188
votes
9 answers

Why do Java programmers like to name a variable "clazz"?

I've seen lots of code with declarations like Class clazz. Where does this originate from? Is this some kind of convention? I think ‘clazz’ is not even an English word, has no meaning at all, how can so many programmers name a wrong name…
Sawyer
  • 15,581
  • 27
  • 88
  • 124
186
votes
6 answers

What are conventions for filenames in Go?

I could find the conventions for naming packages in Go: no underscore between words, everything lowercase. Does this convention apply to the filenames too? Do you also put one struct in one file as if you did for a java class and then name the file…
david
  • 2,467
  • 3
  • 14
  • 13
183
votes
13 answers

Boolean method naming readability

Simple question, from a readability standpoint, which method name do you prefer for a boolean method: public boolean isUserExist(...) or: public boolean doesUserExist(...) or: public boolean userExists(...)
Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
182
votes
4 answers

Is there a naming convention for Django apps

Is there a preferred naming convention for creating a Django app consisting of more than one word? For instance, which of the following is preferred? my_django_app my-django-app Update: Not allowed syntactically mydjangoapp Recommended…
Matthew Rankin
  • 457,139
  • 39
  • 126
  • 163
181
votes
31 answers

Why use prefixes like m_ on data members in C++ classes?

A lot of C++ code uses syntactical conventions for marking up data members. Common examples include m_memberName for public members (where public members are used at all) _memberName for private members or all members Others try to enforce using…
VoidPointer
  • 17,651
  • 15
  • 54
  • 58
178
votes
24 answers

What should I name a table that maps two tables together?

Let's say I have two tables: Table: Color Columns: Id, ColorName, ColorCode Table: Shape Columns: Id, ShapeName, VertexList What should I call the table that maps color to shape? Table: ??? Columns: ColorId, ShapeId
devuxer
  • 41,681
  • 47
  • 180
  • 292
170
votes
7 answers

Does the use of the "Async" suffix in a method name depend on whether the 'async' modifier is used?

What is the convention for suffixing method names with "Async"? Should the "Async" suffix be appended only to a method that is declared with the async modifier? public async Task ConnectAsync() Or is it enough that the method just returns…
kasperhj
  • 10,052
  • 21
  • 63
  • 106
160
votes
3 answers

Naming convention for unique constraint

Naming conventions are important, and primary key and foreign key have commonly used and obvious conventions (PK_Table and FK_Table_ReferencedTable, respectively). The IX_Table_Column naming for indexes is also fairly standard. What about the…
Kirk Broadhurst
  • 27,836
  • 16
  • 104
  • 169
158
votes
12 answers

What package naming convention do you use for personal/hobby projects in Java?

I'm already familiar with the standard Java package naming convention of using a domain name to create a unique package name (i.e. package com.stackoverflow.widgets). However, I've never seen any recommendations for how to choose package names for…
Mike Spross
  • 7,999
  • 6
  • 49
  • 75
152
votes
5 answers

Generic type parameter naming convention for Java (with multiple chars)?

In some interfaces I wrote I'd like to name generic type parameters with more than one character to make the code more readable. Something like.... Map Instead of this... Map But when it comes to methods, the type-parameters look…
chaper29
  • 1,529
  • 2
  • 10
  • 3
149
votes
3 answers

Git flow release branches and tags - with or without "v" prefix

I have seen multiple contradicting definitions on various git flow related websites. Is there an official recommendation or single source of truth? Branches: release-1.2.3 or release-v1.2.3 Tags: 1.2.3 or v1.2.3
friederbluemle
  • 33,549
  • 14
  • 108
  • 109
148
votes
11 answers

Should I use name mangling in Python?

In other languages, a general guideline that helps produce better code is always make everything as hidden as possible. If in doubt about whether a variable should be private or protected, it's better to go with private. Does the same hold true for…
Paul Manta
  • 30,618
  • 31
  • 128
  • 208
148
votes
6 answers

Naming convention for utility classes in Java

When writing utility classes in Java, what are some good guidelines to follow? Should packges be "util" or "utils"? Is it ClassUtil or ClassUtils? When is a class a "Helper" or a "Utility"? Utility or Utilities? Or do you use a mixture of them? The…
JR.
  • 5,840
  • 9
  • 31
  • 34