Skip to main content
Share Your Experience: Take the 2024 Developer Survey
3 votes

End method in normal flow versus exception flow

It really depends on your use-case. In general I would say that @Kilian Foth's answer is perfectly valid, but there might be cases where it would be more readable the other way around. Consider this: ...
Mathieu's user avatar
  • 1,010
3 votes

End method in normal flow versus exception flow

if is supposed to do something when a condition is true, and else something else when it is false. Therefore, the general recommendation is that you should write if(condition) { action } else { ...
Kilian Foth's user avatar
2 votes

End method in normal flow versus exception flow

Guard conditions are an exceptionally well know pattern, so well know that it's known outside of the "Programming Pattern's" world. Guard conditions generally make your code easier to read ...
jmoreno's user avatar
  • 11k
1 vote

Should I really use all uppercase for my constants?

Yes. Python lacks a const keyword, so all caps is a way to remind the programmer to not reassign to that variable. Pylint doesn't appear to check for reassignments however, but adding a type hint ...
Cees Timmerman's user avatar

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