56

the coding standard at my new company
#FML

Comments
  • 9
    You guys using c#?
  • 16
    My company had the same new-line curly brace standard when I started there a few years ago. I got used to it and now find it hard not to.
  • 6
    Boooo. But whatever. I am not sure there is a legit case one way or the other. Someone's preference. Probably not a hill to die on.
  • 11
    @devTea came to the comments to ask the same question.

    For me, curly braces on new lines feels completely natural in C#. Likewise, having them on the same line as other text feels completely natural to me in JavaScript. Standards in languages differ, and that's OK.
  • 4
    At least you don’t have to compare True to the output of SomeTest() in the if.
  • 11
    Oh, I have one.

    If(true)
    Do something

    No brackets. Discuss.

    It makes me want to wretch even typing the example. I think younger devs like this.
  • 7
    @funkyboss I hate a lack of curly braces. I don't usually hate coding style/standard, but the lack of them kills me inside.
  • 2
    @duckWit @devTea yeah it's for c#
  • 6
    @fuckWindows well I don’t really mind both format, also the without curly braces only work on a single line anyway, it’s not that bad
  • 7
    @SauceBoss @funkyboss @devTea see this
    they don't even allow no braces for single statements in if
  • 5
    @Stebner55 at least I know I am not completely nuts then. Unless you are, in which case, my condolences.
  • 10
    @fuckWindows
    String s = someTest() ? "yes" : "no" ;
    What about their view on this?
  • 5
    Auto-formatting
  • 5
    2nd makes sense, having single line ifs without braces are easy to oversee and you would introduce bugs if you edit that code 2 weeks later
  • 5
    Dude, you are a professional. If you cant accept their coding standards, go back playing with your code at home. Those coding standards are not unreasonable.
  • 3
    @StopMotionCuber i dissagree, single lines ifs curlies are usually clutter, so i remove them. with good indentation, they become clearly visible
  • 2
    @irene stop spreading your biased best practixes ;)
  • 1
    @funkyboss i like this, because {} is a lot of clutter and more structure to process for the eye. But really, its case dependent.Another problem of braces is that they obfuscate variables that I created
  • 1
    @gnulinuxer4fun It's still easy to oversee them missing (as indentation would be there anyway) and add a second statement that is not contained in the if but should be.
    I agree that for some devs this will not be overseen, but that is definitely not the case for everyone
  • 2
    Must. Waste. More. Space.
  • 2
    It’s only a matter of how you set up your code formatter
  • 2
    i guess my personal coding style violates everything then Oo.
  • 0
    @irene i grew quite fond of them, although the === looks a tad bit weird, but the >= thingies are nice
  • 2
    @filthyranter This. I never understood why people complain about certain styles. You will get used to it in no time, just use an auto formatter and focus on the code instead of the style.
  • 1
    I don't understand where is the problem in having to add braces for a single line if statement, I find it much much better for readability better than having multiple lines right under each other and not being able to glance that there is an if statement there.
    Whenever I debug something I don't read my code, I skim over it for a specific thing, and in cases of wrong if conditions, its easier and faster to find.

    As for me I hate Java formatting style, I've been a long time C# developer and I like and am used to their style, but to each language/company their own format unless I am introducing a really better format (which never happened, as we use default format for the language)

    Just like tabs/spaces, as long as the code is indented who cares?
  • 4
    What does it matter? It's there to make sure coding style is consistent between different devs, otherwise it would become a big mess when everyone applies their own style and people will waste lots of time discussing styles.

    In the end, it doesn't matter. You'll get used to it quickly and if you don't, well, no offence, but maybe then you should go do something different.
  • 2
    I use to fight some of these minor standards years ago. I got beaten into submission ;)
  • 4
    @gitpush Amen to that! Using braces for single line ifs etc. is in fact highly recommended in terms of quality. And nowadays, code quality is quite a big deal. As such, most quality assessment tools will report such missing braces as violations impacting the code quality in a negative way.
  • 0
    @BurnoutDV Although perfectly legal, in terms of code quality and especially maintainability it is considered bad practice because it is very easy to introduce new bugs due to missing braces. Guess your code never changes so maintainability is not an issue, or at least no one else will ever need to maintain it ;)
  • 0
    Wait until someone enforces semicolon on every end of statement in JavaScript 😂

    Now that I know better on how JS works underneath... It's actually a valid practice
  • 0
    @CodeMasterAlex Do you know of any free code quality tools? I've found some online, but I need it for my personal projects which basically are for learning purposes
  • 0
    As it should be
  • 1
    @gitpush have a look at SonarQube. I think they have a free community edition. I'm currently writing such a tool myself in Rascal but that's for java only and is a study assignment.
  • 0
    @BurnoutDV if you removed your comments, id like your code ;)
  • 0
    @edwardcjk i actually do that..not cause its enforced but because i usually only create small webapps that use a mixture of php and javascript and i would forget so many semikolons in php.
  • 0
    @gnulinuxer4fun i am a storywriter in camouflage. I should really cut it down though :/
  • 0
    @CodeMasterAlex Thanks man much appreciated, and good luck completing your assignment :)
  • 0
    The only thing that really bothers me is the missing whitespace in both examples.
  • 1
    @BurnoutDV That is honestly horrible. At least be consistent.
  • 1
    @Semmel i aim to please (:
  • 1
    @gitpush for me it comes down to something you mentioned: when reviewing code on the first pass or in an emergency, I would prefer that there is as little ambiguity due to style as possible. Having brackets sometimes required is more ambiguous than always using brackets. The compiler sees them as the same thing, but in that case why use any CRLF at all? Why use indentation?

    I also agree that the braces do not matter, so long as there is a single standard. However, when I am picking the standards I will ask our devs to use braces every time.

    I use the old Van Halen brown M & Ms approach. Braces and other style choices are the brown M &Ms. If I find them, there will likely be bigger problems that cannot be ignored.

    For those who do not know, Van Halen asked for M & M's in their contracts, brown ones removed. If they appeared to a bowl full of unfiltered M & M's, they knew to expect trouble due to lack of attention to detail.
  • 1
    @funkyboss great point there, though to think of it to each his own readability preference, lets hope the goal is to make it as readable as possible to at least existing dev team
  • 1
  • 1
    @BurnoutDV Yea, comments are bad, IMHO.

    They increase laze. Suddenly its "oh my code is unreadable. lets slap in a comment" instead of "oh my code is unreadable, lets refactor it"
  • 0
    It’s standard for C#. Unreal also recommend same format in C++. Btw they use tab instead of space 😈
    Every company has own standard for js code and very few use “standard”
    My suggestion is follow the requirement or star your own company
  • 0
    Leave the company
  • 0
    @fuckWindows That rule doesn't make any sense imho. Why would you not have a space after an if? Also the examples compare apples to oranges afaict. Where is this from?
  • 0
    Whats their standards for style regarding tabs OR spaces?

    Only one answer is correct.
  • 0
    @Wabby no tabs only spaces
  • 0
    @fuckWindows @irene WOW. Both wrong. Who would have thought? 🤣
  • 0
    @irene I bet you use MS word for Documentation and Readme files aswell then.
  • 0
    @irene it was a generalisation of space users. I don’t even code.
  • 0
    @iamavalos TLDR but I'll give you the ++ anyway
  • 0
    @fuckWindows Leave the company ASAP.
  • 0
    If it’s JavaScript it’s weird. Php is becoming more norm then it was. C# is expected
Add Comment