Code Blocks

  • Comments posted to this topic are about the item Code Blocks

  • Personally I think the query compiler should mandate BEGIN END for this construction.

  • We have in-house standards that say block designators are required (any programming language), even if there's only one statement in the block. Eliminates any chance of confusion (human or compiler/interpreter). Started 30+ years ago, with COBOL IF END-IF, etc. Programmers hated it at the time, but it's a QA failure now.

  • I was reviewing a PR today and had a minor disagreement with the dev because I took exception to his failure to use braces (C#)

    if (myVar == otherVar)

    return true;

    instead of

    if (myVar == otherVar)

    {

    return true;

    }

    I'm sure he thought I was being pedantic but I still remember a very subtle bug caused by someone mistaking indentation for scope.

  • Hahaha!!!!

  • I thought that also. So I ran a test. The compiler does not care. This runs and runs and runs.

    • This reply was modified 1 month ago by  edmil.
  • As a developer, there's nothing wrong with no braces. I would prefer it look like this though:

    if (myVar == otherVar) return true;

    It's more obvious what's going on when it looks like this.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply