Give meaning and explanation with the fewest number of characters in a form that is most accepted by your team or community at large.

learn more… | top users | synonyms

126
votes
19answers
32k views

Why is naming a table's Primary Key column “Id” considered bad practice? [closed]

My t-sql teacher told us that naming our PK column "Id" is considered bad practice without any further explanations. Why is naming a table PK column "Id" is considered bad practice?
105
votes
17answers
21k views

Is there an excuse for short variable names?

This has become a large frustration with the codebase I'm currently working in; many of our variable names are short and undescriptive. I'm the only developer left on the project, and there isn't ...
76
votes
16answers
19k views

What is the benefit of not using Hungarian notation?

One of the things I struggle with is not using Hungarian notation. I don't want to have to go to the variable definition just to see what type it is. When a project gets extensive, it's nice to be ...
69
votes
27answers
37k views

Naming conventions: camelCase versus underscore_case ? what are your thoughts about it? [closed]

I've been using underscore_case for about 2 years and I recently switched to camelCase because of the new job (been using the later one for about 2 months and I still think underscore_case is better ...
65
votes
1answer
12k views

Should package names be singular or plural?

Often, in libraries especially, packages contains classes that are organized around a single concept. Examples: xml, sql, user, config, db. I think we all feel pretty naturally that these packages ...
64
votes
6answers
6k views

Should the variable be named Id or ID?

This is a bit pedantic, but I've seen some people use Id as in: private int userId; public int getUserId(); and others use: private int userID; public int getUserID(); Is one of these a better ...
62
votes
14answers
13k views

What “version naming convention” do you use? [closed]

Are different version naming conventions suited to different projects? What do you use and why? Personally, I prefer a build number in hexadecimal (e.g 11BCF), this should be incremented very ...
48
votes
16answers
6k views

Is it bad to use Unicode characters in variable names?

I recently tried to implement a ranking algorithm, AllegSkill, to Python 3. Here's what the maths looks like: No, really. This is then what I wrote: t = (µw-µl)/c # those are used in e ...
46
votes
5answers
5k views

Why is Inversion of Control named that way?

The words invert or control are not used at all to define Inversion of Control in the definitions that I've seen. Definitions Wikipedia inversion of control (IoC) is a programming technique, ...
40
votes
7answers
3k views

How to name a variable when the word is both a noun and a verb

I have run into a corner-case problem with the general guidance of: nouns for variables verbs for functions Specifically, I have a case where the word is ambiguous - it can be either a verb or a ...
37
votes
11answers
3k views

Why are cryptic short identifiers still so common in low-level programming?

There used to be very good reasons for keeping instruction / register names short. Those reasons no longer apply, but short cryptic names are still very common in low-level programming. Why is this? ...
34
votes
15answers
4k views

Is it bad practice to name an unused variable with a single underscore?

Often when the syntax of the language requires me to name a variable that is never used, I'll name it _. In my mind, this reduces clutter and lets me focus on the meaningful variables in the code. I ...
32
votes
6answers
4k views

Should interface names begin with an “I” prefix?

I have been reading "Clean Code" by Robert Martin to hopefully, become a better programmer. While none of it so far has been really ground breaking it has made me think differently about the way I ...
30
votes
9answers
2k views

Why do old C-style method names continue being used in modern languages?

I understand that in the earlier days of computing, shorter method names like printf made sense, because storage was limited. But why do modern languages like Python and Go still use the less readable ...
30
votes
9answers
3k views

How to name a method that both performs a task and returns a boolean as a status?

If there is a method bool DoStuff() { try { // doing stuff... return true; } catch (SomeSpecificException ex) { return false; } } should it rather be called ...
30
votes
11answers
2k views

Intentional misspellings to avoid reserved words

I often see code that include intentional misspellings of common words that for better or worse have become reserved words: klass or clazz for class: Class clazz = ThisClass.class kount for count in ...
28
votes
9answers
2k views

Is it considered poor practice to include a bug number in a method name for a temporary workaround?

My coworker who is a senior guy is blocking me on a code review because he wants me to name a method 'PerformSqlClient216147Workaround' because it's a workaround for some defect ###. Now, my method ...
27
votes
17answers
3k views

Is it a good practice to name the returned variable “result”? [closed]

Is it a good practice to call the variable a method returns with a variable name result? For instance: public Zorglub calculate() { Zorglub result = [...] [...] return result; } Or ...
27
votes
6answers
979 views

In what language should I name my business classes?

I'm requesting best practice with this question. This is only an issue if the customer company is strictly national has a native language other than English, I think. If the customer has a lot of ...
26
votes
9answers
2k views

Scientific evidence that supports using long variable names instead of abbreviations?

Is there any scientific evidence that the human brain can read and understand fully written variable names better/faster than abbreviated ones? Like PersistenceManager persistenceManager; in ...
25
votes
9answers
3k views

Why should identifiers not begin with a number?

Most programming languages appear to be designed to not allow one to declare an identifier that starts with a number. I was just curious to know the reason. I have already searched the web, but ...
25
votes
10answers
4k views

What naming anti-patterns exist? [closed]

There are some names, where if you find yourself reaching for those names, you know you've already messed something up. For example: XxxManager This is bad because a class should describe what the ...
23
votes
7answers
12k views

Practical considerations for HTML / CSS naming conventions (syntax) [closed]

Question: what are the practical considerations for the syntax in class and id values? Note that I'm not asking about the semantics, i.e. the actual words that are being used, as for example ...
20
votes
13answers
3k views

Is Systems Hungarian notation still a useful practice? [closed]

I searched the forum, but I couldn't find the answers why it should be avoided, only why it's not a silver bullet. So I don't think this question is a duplicate. Is there a VALID reason why I should ...
20
votes
17answers
10k views

How do you name your private variables in C#? [closed]

What is the best practice, most commonly accepted naming conventions for private variables in C#? private int myInteger; private int MyInteger; private int mMyInteger; private int _myInteger; ...
20
votes
4answers
5k views

Classes naming: singular or plural?

It is always difficult for me to choose between singular and plural forms for classes names: CustomerRepository vs. CustomersRepository CustomerService vs. CustomersService CustomerController vs. ...
20
votes
8answers
917 views

Are there good techniques or tests for naming types?

An awkward, open question, but it's a problem I'm always bumping against: Software that's easy to maintain and work with is software designed well. Trying to make a design intuitive means naming your ...
20
votes
2answers
2k views

Should one always know what an API is doing just by looking at the code?

Recently I have been developing my own API and with that invested interest in API design I have been keenly interested how I can improve my API design. One aspect that has come up a couple times is ...
19
votes
10answers
2k views

[YYYY].[MM].[DD].[hh][mm] vs. [major].[minor].[revision] [duplicate]

Possible Duplicate: What “version naming convention” do you use? I am currently debating between the traditional versioning convention [major].[minor].[revision] and my own, ...
18
votes
8answers
910 views

How and why to decide between naming methods with “get” and “find” prefixes

I always have trouble figuring out if I should name a certain method starting with getSomething versus findSomething. The problem resides in creating helpers for poorly designed APIs. This usually ...
18
votes
5answers
7k views

Is the Java package name convention flawed? [closed]

We're all familiar with the Java package name convention of turning the domain name around. I.e. www.evilcorp.com would, by convention, chose to have their java packages com.evilcorp.stuff. ...
18
votes
3answers
466 views

“My stuff” vs. “Your stuff” in UI texts

When refering to a users stuff should you use My or Your, for example: My Cart | My Account | My Wishlist Or Your Cart | Your Account | Your Wishlist I found this article that argues for ...
18
votes
6answers
318 views

Should the internal naming (classes, methods, database tables, etc) of entities be changed if the marketing and UI naming changes?

We've had a long living product for about 8 years now. Over time, the names of concepts and entities change. Should we put the work in to rename all the code base and database tables and columns to ...
17
votes
7answers
1k views

Why is XML not called EML?

From Wikipedia Extensible Markup Language (XML) is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification[4] produced by the W3C, and several ...
17
votes
5answers
2k views

What are the benefits of prefixing function parameter names with p*?

I often see projects (in Java projects and teams using Eclipse) that prefix function parameters with p. For example public void filter (Result pResult) ... I personally don't see any benefit in ...
16
votes
4answers
2k views

Is it ever a good idea to use the design pattern name in the implementing classes?

Recently I came across a moderately large python codebase with lots of MyClassAbstractFactory, MyClassManager, MyClassProxy, MyClassAdapter etc. classes. While on the one hand those names pointed me ...
16
votes
13answers
2k views

Are short abbreviated method/function names that don't use full words bad practice or a matter of style?

Is there nowadays any case for brevity over clarity with method names? Tonight I came across the Python method repr() which seems like a bad name for a method to me. It's not an English word. It ...
16
votes
2answers
1k views

Boolean Method Naming Affirmative vs Negative

Should boolean methods always take the affirmative form, even when they will only ever be used in the negative form? Say I wanted to check whether an entity exists before creating one, my argument is ...
16
votes
3answers
930 views

How to camel-case where consecutive words have numbers?

Just wondering if anybody has a good convention to follow in this corner-corner-corner case. I really use Java but figured the C# folks might have some good insight too. Say I am trying to name a ...
15
votes
3answers
1k views

Is it poor practice to name a property/member the same as the declaring type in C#?

For instance, a class like: class Dog { } //never mind that there's nothing in it... and then a property like: Dog Dog { get; set; } I've been told that if I can't come up with a more ...
15
votes
6answers
706 views

“A”, “an”, and “the” in method and function names: What's your take? [closed]

I'm sure many of us have seen method names like this at one point or another: UploadTheFileToTheServerPlease CreateATemporaryFile WriteTheRecordToTheDatabase ResetTheSystemClock That is, method ...
15
votes
9answers
5k views

Default vs Impl when implementing interfaces in Java

After reading Should package names be singular or plural? it occurred to me that I've never seen a proper debate covering one of my pet peeves: naming implementations of interfaces. Let's assume ...
15
votes
2answers
4k views

c# class naming standards/guidelines

Over the years I've used various naming conventions for services in my applications for example: [ClassName]Service [ClassName]Manager [ClassName]Factory [ClassName]Provider ...
14
votes
5answers
3k views

Why it is called “hash table”, or “hash function”? Hash doesn't make any sense to me here

It's now about 4 years of development that I'm using, hearing, talking about, and implementing hash tables and hash functions. But I really never understand why it's called hash? I remember the first ...
14
votes
13answers
1k views

async & await - poll for alternatives [closed]

Now that we know what is in store for c#5, there is apparently still an opening for us to influence the choice of the two new keywords for 'Asynchrony' that were announced by Anders Heijsberg ...
14
votes
5answers
2k views

Naming your software and uniqueness

When it comes to naming your software product (whether an application or a library), what do you do? It seems impossible to choose a name which isn't already taken by some other piece of software, ...
13
votes
9answers
653 views

What do you do when your naming convention clashes with your language?

Okay, this is one of those little things that always bugged me. I typically don't abbreviate identifiers, and the only time I use a short identifier (e.g., i) is for a tight loop. So it irritates me ...
13
votes
8answers
1k views

A Class named Class?

This is more of a style question, but it is something I am currently pondering for a project of mine. Assume that you're creating an application which is modeling a school. So there are entities like ...
13
votes
7answers
711 views

What is more standard shortening for “regular expression”, “regex” or “regexp”? [closed]

I want to know what is more standard way to call regular expression in short way. I have seen both, regex and regexp. Google says regex has almost 2 as much hits that regexp, but it depends on way I ...
13
votes
4answers
1k views

The problems with Avoiding Smurf Naming classes with namespaces

I pulled the term smurf naming from here (number 21). To save anyone not familiar the trouble, Smurf naming is the act of prefixing a bunch of related classes, variables, etc with a common prefix so ...