24
votes
Accepted
Using `any` to indicate a wildcard value
Instead of using a sentinel value like any or None with special-cased logic, you could create a type the implements the desired "everything goes" behavior using the same interface as the ...
8
votes
Common practice where to place "is" word while naming predicate function: at the beginning or in the middle?
This inconsistency is a combination of things:
Language designers are not required to adopt naming conventions from other languages when inventing a new programming language.
Naming conventions have ...
7
votes
When to prefer print over logging?
Printing and logging serve different purposes.
The purpose of logging tools is that they provide you with information after the fact about what a piece of software was doing. These tools are designed ...
6
votes
Using `any` to indicate a wildcard value
I made the types Anything and Something for this purpose. Anything compares True with any other value, while Something compares True on anything that is not None:
>>> Anything == 42
True
>&...
5
votes
Using `any` to indicate a wildcard value
Here's another solution similar to Brian61354270's answer that's a little more generic. You might want to use this if you have to support other rules that are more complicated. As an example, I ...
5
votes
Common practice where to place "is" word while naming predicate function: at the beginning or in the middle?
One main reason might be that the "noun" in your hypothetical examples is a variable or an expression on which the predicate is applied, so it would be redundant to specify it in the name of ...
4
votes
When to prefer print over logging?
Each has it's own capabilities.
Print lets you write:
to a hard coded file path
to stdout
to stderr
only what you say to write
Logging lets you write
to a user configured file path
to a user ...
1
vote
Common practice where to place "is" word while naming predicate function: at the beginning or in the middle?
"is" or in some cases "has" should be the first part of the method name. For example
bool nothingThere = box.isEmpty()
bool nobodyThere = !car.hasPassengers();
Without the is I ...
1
vote
Declaring code style settings in a Java project
OP did not describe the proposed changes
to default format (TAB == three SPACE, maybe?).
More importantly, it did not describe the
positive benefit which would outweigh
the various frictional ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
coding-style × 1050coding-standards × 148
java × 103
c++ × 98
code-quality × 93
python × 76
programming-practices × 76
c# × 73
clean-code × 69
design × 53
c × 53
object-oriented × 45
javascript × 45
naming × 45
readability × 37
php × 27
design-patterns × 26
language-agnostic × 24
comments × 22
conditions × 19
refactoring × 18
code-reviews × 18
architecture × 17
exceptions × 16
functions × 16