As of May 31, 2023, we have updated our Code of Conduct.
299 votes
Accepted

Python file naming convention?

Quoting https://www.python.org/dev/peps/pep-0008/#package-and-module-names: Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. ...
agold's user avatar
  • 3,106
189 votes

Naming issues: Should "ISomething" be renamed to "Something"?

Whilst many, including "Uncle Bob", advise not to use I as a prefix for interfaces, doing so is a well-established tradition with C#. In general terms, it should be avoided. But if you are writing C#, ...
David Arno's user avatar
  • 38.9k
175 votes
Accepted

Coding standard for clarity: comment every line of code?

Michael Durrant's answer is IMHO not bad, but it is not literally answering the question (as he admitted by himself), so I'll try to give an answer which does: I also understand that comments should ...
Doc Brown's user avatar
  • 196k
154 votes

Coding standard for clarity: comment every line of code?

Major anti-pattern leading to poor quality code with less clarity btw readers, the title was originally "comment every line of code?" and you can imagine the instinctive reaction of many of us, ...
Michael Durrant's user avatar
129 votes
Accepted

Naming of bool methods: Is vs. Can vs.?

Is vs. Can According to the Microsoft naming convention recommendations, both "Is" and "Can" are OK (and so is "Has") as a prefix for a Boolean. In plain English, "Is" would be used to identify ...
John Wu's user avatar
  • 25.8k
78 votes

Python file naming convention?

Here is a link for different types of Python name conventions. The style guide for Python is based on Guido’s naming convention recommendations.
Vlad Bezden's user avatar
68 votes

Best Practice - Avoid naming class and field the same?

Bart van Ingen Schenau has some good advice, but I'd like to offer some additional advice. Don't universally avoid naming a class and property the same, but definitely question it. Consider all of the ...
Greg Burghardt's user avatar
62 votes
Accepted

Why does software use the Win32 name?

Win32 is the customary name for the Windows API. This API specifies how applications can interface with the operating system. It is roughly comparable with the POSIX standard on Unix, but Win32 also ...
amon's user avatar
  • 131k
52 votes
Accepted

Are "plus" and "minus" appropriate method names?

The only reason I can think of is that dates are immutable objects, so by calling plusDays you're not adding days to the original object but creating a new one with new properties, but that's very ...
Ben Aaronson's user avatar
  • 6,853
41 votes
Accepted

Readme.txt vs. README.txt

All-uppercase letters stand out and make the file easily visible which makes sense because it is probably the first thing a new user would want to look at. (Or, at least, should have looked at…) As ...
5gon12eder's user avatar
  • 6,936
41 votes

Naming issues: Should "ISomething" be renamed to "Something"?

The interface is the important logical concept, hence, the interface should carry the generic name. So, I'd rather have interface Something class DefaultSomething : Something class MockSomething : ...
wallenborn's user avatar
  • 1,972
40 votes

Why are module-specific prefixes widely used for function names in C modules?

Why prefixes in the first place? The prefix for function names is a C practice that intends to avoid naming conflicts. This is especially suitable in big projects, where different teams could easily ...
Christophe's user avatar
  • 72.6k
40 votes

Best Practice - Avoid naming class and field the same?

Fields/properties/attributes within a class should describe something of the concept that you are modelling with that class. You should be able to ask questions like "What is the <property> ...
Bart van Ingen Schenau's user avatar
30 votes

Why does software use the Win32 name?

Because the Windows API is 30+ years old and has been around when PC's were 16-bit, then 32-bit came along, then Win32s, then win64. There is platform dependence in windows development, and you need ...
Thomas Carlisle's user avatar
29 votes

Naming issues: Should "ISomething" be renamed to "Something"?

This isn't just about naming conventions. C# doesn't support multiple inheritance so this legacy use of Hungarian notation has a small albeit useful benefit where you're inheriting from a base class ...
Robbie Dee's user avatar
  • 9,717
26 votes

What form of verb to use (imperative verb or third-person verb) in programming?

var val = obj.GetValue(); var val = obj.PlayOnAwake; // From Unity It's not first-person, it's imperative. Simply put, it's a command. GetValue() Get the value! PlaySound() Play this sound! ...
Flater's user avatar
  • 41.7k
24 votes

Coding standard for clarity: comment every line of code?

I don't think a coding standards document is the place to specify what is already common sense. The purpose of a coding standard is to guarantee consistence (and avoid arguments) about issues where ...
JacquesB's user avatar
  • 56.8k
24 votes

C# - Why are prefixes on fields discouraged?

When they were working on the API for Windows, Microsoft recommended the use of Hungarian Notation, using 'm_', as well as 'i', 'sz', etc. At the time, this was useful because the IDE wasn't robust ...
Kevin Fee's user avatar
  • 2,837
23 votes
Accepted

How to name a Boolean variable that represents either of two options?

Don't use a Boolean. Use an enum. E.g TransactionType with instances Buy and Sell. That is unambiguous and far easier to understand. If you want to persist the data efficiently, the boolean can be a ...
marstato's user avatar
  • 4,528
22 votes

Why does convention say DB table names should be singular but RESTful resources plural?

The REST spec (whatever level you want to go with) wasn't designed as database access. It is trying to bring standardization to API access. The SQL conventions mentioned (whether you want to use them ...
Kasey Speakman's user avatar
22 votes

How should I name functions that return values in Python?

Use verbs where reasonable, nouns if they are shorter and unambiguous Most of the time, functions should be (imperative) verbs and classes, variables, and parameters should be nouns. Attributes ...
Kevin's user avatar
  • 2,648
21 votes

Readme.txt vs. README.txt

Traditionally the file was called README in uppercase because command-line environments that use alphabetical ordering would then put the file at the top. This makes them easily visible in big ...
JDT's user avatar
  • 6,272
20 votes

Coding standard for clarity: comment every line of code?

It is not possible. What you are essentially trying to do is nearly to mechanize good judgment. When writing critical software such as for life supporting medical systems, huge amounts of checklists ...
whatsisname's user avatar
  • 27.4k
19 votes
Accepted

Is it a good practice to end a function's name with a preposition?

If it adds meaningful clarification or fits the "ethos" ... Yes. .NET's OrderBy() and ElementAt() might be good examples. Personally, I like code that reads pretty much like English. It takes a ton ...
svidgen's user avatar
  • 13.3k
18 votes
Accepted

What are the standards for dealing with pluralia tantum in your code?

I do not think there is a standard for this. The majority of english nouns does not come with this problem. So if you do not want to add a term like "list" or "collection" to the variable name, a ...
Doc Brown's user avatar
  • 196k
17 votes

Naming issues: Should "ISomething" be renamed to "Something"?

No no no. Naming conventions are not a function of your Uncle Bob fandom. They are not a function of the language, c# or otherwise. They are a function of your code base. To a much lesser extent ...
candied_orange's user avatar
17 votes

Naming of bool methods: Is vs. Can vs.?

It's worth mentioning that the "should" prefix can also be used. According to Apple's guideline, not just "can" and "should", modal verbs in general can be used to name functions that return boolean. ...
Harry's user avatar
  • 195
17 votes

Why are module-specific prefixes widely used for function names in C modules?

There are two important types of naming collisions here. You are correct in that the compiler won't have any trouble differentiating between the functions due to scope rules. Your problem is that ...
bta's user avatar
  • 955
16 votes

C# - Why are prefixes on fields discouraged?

C# doesn't have any global variables, so that leaves only local variables and class-fields. And if you have so many local variables you lose track of whether an identifier is one, you have most ...
Deduplicator's user avatar
  • 8,503

Only top scored, non community-wiki answers of a minimum length are eligible