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
107
votes
4 answers

CFLAGS, CCFLAGS, CXXFLAGS - what exactly do these variables control?

I am using GNU make to compile my C++ code, and i would like to understand how to make my compilations customizable. I read in different places that CFLAGS, CCFLAGS and CXXFLAGS are used for this purpose. So how should i use them? If i have…
anatolyg
  • 26,506
  • 9
  • 60
  • 134
107
votes
13 answers

Is there a standard naming convention for XML elements?

Is there any standard, de facto or otherwise, for XML documents? For example which is the "best" way to write a tag? Likewise if I have an enumerated value for an attribute which is better
tpower
  • 56,100
  • 19
  • 68
  • 100
103
votes
5 answers

Is there a convention to name collection in MongoDB?

I would like to know if there is a convention for database collections such as: PageVisit or page_visit. Are there any advantages/disadvantages for these notations?
johnlemon
  • 20,761
  • 42
  • 119
  • 178
102
votes
13 answers

Primary key/foreign Key naming convention

In our dev group we have a raging debate regarding the naming convention for Primary and Foreign Keys. There's basically two schools of thought in our group: 1: Primary Table (Employee) Primary Key is called ID Foreign table (Event) Foreign…
Jeremy
  • 44,950
  • 68
  • 206
  • 332
101
votes
3 answers

Haskell: why the convention to name a helper function "go"?

I see go a lot when reading Haskell material or source, but I've never been really comfortable about it - (I guess it has the negative connotation of "goto" in my mind). I started learning Haskell with LYAH, and that's where I picked up the tendency…
Dan Burton
  • 53,238
  • 27
  • 117
  • 198
99
votes
9 answers

Naming convention for assets (images, css, js)?

I am still struggling to find a good naming convention for assets like images, js and css files used in my web projects. So, my current would be: CSS: style-{name}.css examples: style-main.css, style-no_flash.css, style-print.css…
Max
  • 15,693
  • 14
  • 81
  • 131
98
votes
8 answers

C# naming convention for enum and matching property

I often find myself implementing a class maintaining some kind of own status property as an enum: I have a Status enum and ONE Status property of Status type. How should I solve this name conflict? public class Car { public enum Status { …
Serge Wautier
  • 21,494
  • 13
  • 69
  • 110
95
votes
33 answers

Am I immoral for using a variable name that differs from its type only by case?

For instance, take this piece of code: var person = new Person(); or for you Pythonistas: person = Person() I'm told constantly how bad this is, but have yet to see an example of the immorality of these two lines of code. To me, person is a…
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
94
votes
8 answers

How do you PEP 8-name a class whose name is an acronym?

I try to adhere to the style guide for Python code (also known as PEP 8). Accordingly, the preferred way to name a class is using CamelCase: Almost without exception, class names use the CapWords convention. Classes for internal use have a…
Escualo
  • 40,844
  • 23
  • 87
  • 135
94
votes
4 answers

How should I name a java.util.Map?

I have a java.util.Map that maps from a logical name to a set of parameters to use with that name. Map howShouldINameThee = ...; What is the best name for this map? Should I go simple and just call this parameters or…
Alex B
  • 24,678
  • 14
  • 64
  • 87
93
votes
3 answers

What does the dot mean in R – personal preference, naming convention or more?

I am (probably) NOT referring to the "all other variables" meaning like var1~. here. I was pointed to plyr once again and looked into mlplyand wondered why parameters are defined with leading dot like this: function (.data, .fun = NULL, ...,…
Matt Bannert
  • 27,631
  • 38
  • 141
  • 207
93
votes
21 answers

What's a good name for a method that gets or creates an object?

Say you have a cache, and a method that will do something like the following: if (wanted Foo is not in cache) cache.Add(new Foo()) Return Foo from cache What would you call that method? GetFoo(), GetOrCreateFoo() or something else (and better)?…
Tor Livar
  • 1,193
  • 1
  • 9
  • 9
93
votes
4 answers

python: naming a module that has a two-word name

I'm trying to put together a really simple module with one .py source file in it, and have already run into a roadblock. I was going to call it scons-config but import scons-config doesn't work in Python. I found this SO question and looked at PEP8…
Jason S
  • 184,598
  • 164
  • 608
  • 970
93
votes
8 answers

Proper naming convention for a .NET Delegate type?

By convention classes are often named like nouns, methods like verbs and interfaces like adjectives. What is the common naming convention for a delegate? Or what's a good way to differentiate its name when delegates are listed among types and other…
John K
  • 28,441
  • 31
  • 139
  • 229
92
votes
15 answers

What strategy do you use for package naming in Java projects and why?

I thought about this awhile ago and it recently resurfaced as my shop is doing its first real Java web app. As an intro, I see two main package naming strategies. (To be clear, I'm not referring to the whole 'domain.company.project' part of this,…
Tim Visher
  • 12,786
  • 16
  • 58
  • 66