Skip to main content
added 6 characters in body
Source Link
J_H
  • 7.9k
  • 1
  • 18
  • 28

When I read "check" it sounds like we're evaluating for side effects, such as logging that a check failed or raising an exception. So we might call checkFirstInvariant() and checkSecondInvariant(), expecting them to silenty return because all is well.

When I read "check" it sounds like we're evaluating for side effects, such as logging that a check failed or raising an exception. So we call checkFirstInvariant() and checkSecondInvariant(), expecting them to silenty return because all is well.

When I read "check" it sounds like we're evaluating for side effects, such as logging that a check failed or raising an exception. So we might call checkFirstInvariant() and checkSecondInvariant(), expecting them to silenty return because all is well.

added 257 characters in body
Source Link
J_H
  • 7.9k
  • 1
  • 18
  • 28

When I read "check" it sounds like we're evaluating for side effects, such as logging that a check failed or raising an exception. So we call checkFirstInvariant() and checkSecondInvariant(), expecting them to silenty return because all is well.

When I read "check" it sounds like we're evaluating for side effects, such as logging that a check failed or raising an exception. So we call checkFirstInvariant() and checkSecondInvariant(), expecting them to silenty return because all is well.

added 5 characters in body
Source Link
J_H
  • 7.9k
  • 1
  • 18
  • 28

But start a pair of lines with || so each disjunct is on its own line, and then it reads at least as nicely as Variant2. Possible downside is that during debugging it's harder to set breakpoint where you want it, or to insert statements for "print debugging".

Does that lead to more concise code, in SLOC? Probably not. But itsit's easier to read, and easier to believe that what you're reading is true. It also gives you the opportunity to unit test individual helpers, for added confidence that the code really does what it claims.

But start a pair of lines with || so each disjunct is on its own line, and it reads at least as nicely as Variant2. Possible downside is that during debugging it's harder to set breakpoint where you want it, or to insert statements for "print debugging".

Does that lead to more concise code, in SLOC? Probably not. But its easier to read, and easier to believe that what you're reading is true. It also gives you the opportunity to unit test individual helpers, for added confidence that the code really does what it claims.

But start a pair of lines with || so each disjunct is on its own line, and then it reads at least as nicely as Variant2. Possible downside is that during debugging it's harder to set breakpoint where you want it, or to insert statements for "print debugging".

Does that lead to more concise code, in SLOC? Probably not. But it's easier to read, and easier to believe that what you're reading is true. It also gives you the opportunity to unit test individual helpers, for added confidence that the code really does what it claims.

Source Link
J_H
  • 7.9k
  • 1
  • 18
  • 28
Loading