0

My teacher just saied that C# naming conventions wan't use to always put brackets on our if statements even though their is only one line next to it.

Where did she get this from ? 😅

Comments
  • 4
    From common sense.
  • 7
    You'll stop laughing once you end up with something like this https://imperialviolet.org/2014/02/...
  • 0
    @UnicornPoo Actually, no. People tell me to do it, but i am a little bit shy and i lost hope after some teacher who only want to be right.
  • 0
    @electrineer Then, it is not a convention.
  • 0
    @electrineer It is stupid mistakes, just like you would forget to put semicolons at "the end of your line".
    I personally make my IF statements without brackets, and i've never had issues with that.
    In anyway, that means you are making 2 lines more, to be safe but not to make a clean code and that's not part of any convention.
  • 2
    @suiramdev you could get a bug like that in a merge without actively writing the second line. And you get an error from a missing semicolon, so it's not a problem.

    Additional braces won't save you from additional semicolons, though:

    @highlight
    skip_block = true;
    if (!skip_block) ;
    {
    just_kidding();
    this_runs_every_time();
    }
  • 0
  • 4
    @suiramdev your last comment screams "I'm coding like I want it, fuck everyone else". Not sure if it's intended...

    But you just declared you're not a team player and value your own opinion higher than working together on a code base.

    It doesn't and should never matter if you like braces or not, as it not only prevents bugs but makes the code more readable for everyone.

    In most coding guidelines you will find - no matter what language - braces mandatory for if statements, as it's the sanest approach.
  • 0
    @IntrusionCM That's not how i wanted to express myself but you are right, looking to my projects and how i am always feeling in team, i actually agree that i am not a "team player".
    On my own Personal projects, i actually prefer to remove those brackets because i feel confortable with it, but it is true, it can be realy unconfortable for some peoples.
  • 0
    Tl;dr op were egocentric douchbag
Add Comment