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. ...
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#, ...
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 ...
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, ...
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 ...
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.
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 ...
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 ...
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 ...
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 ...
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 : ...
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 ...
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> ...
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 ...
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 ...
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!
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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. ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
naming-standards × 164naming × 92
coding-standards × 22
c# × 17
java × 10
design × 9
clean-code × 9
conventions × 9
programming-practices × 8
coding-style × 8
python × 7
functions × 7
variables × 7
rest × 6
methods × 6
object-oriented-design × 5
c++ × 4
javascript × 4
c × 4
api-design × 4
terminology × 4
sql × 4
class-design × 4
design-patterns × 3
object-oriented × 3