3 ms·
On this example: if not something: # Unhappy case else: # Happy case To: if something: # Happy case else: # U
by Macha 3y ago
On this example:
if not something:
# Unhappy case
else:
# Happy case
To:
if something:
# Happy case
else:
# Unhappy case
This is the exact kind of rule that some people feel needs to be applied globally and will run into conflicts with rules like "put the shorter case first" so people aren't having to keep multiple cases in their mind at once.
In short it's a preference masked as a best practice, and putting it under the same kind of "oh we should change it for the boy scout rule" logic as things like "Maybe let's not have 1000 line methods" is the exact kind of performative review being complained about.
- Tainnor 3y agoI don't see anything wrong with giving a feedback such as "I would find it easier to understand if it was written lile this...". I'm just stating my preference and if the author agrees (which sometimes happens), or if they don't care, they can change it, otherwise they may also ignore it.
- RadiozRadioz 3y agoAnd sometimes the unhappy case is simply more "important". It's nice when code reads like prose, and matches how you'd describe something using natural language. Perl has the `unless` statement for exactly this purpose. This pattern isn't inherently bad, sometimes it's just what you wanted to say.
- morelisp 3y agoCheck out this guy who thinks it's objectively bad to have 1000 line methods.