Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
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.
-
funkyboss696yBoooo. 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.
-
duckWit56166y@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. -
funkyboss696yOh, 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. -
@funkyboss I hate a lack of curly braces. I don't usually hate coding style/standard, but the lack of them kills me inside.
-
devTea219106y@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
-
funkyboss696y@Stebner55 at least I know I am not completely nuts then. Unless you are, in which case, my condolences.
-
-
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
-
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.
-
@StopMotionCuber i dissagree, single lines ifs curlies are usually clutter, so i remove them. with good indentation, they become clearly visible
-
@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
-
@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 -
@irene i grew quite fond of them, although the === looks a tad bit weird, but the >= thingies are nice
-
csuvbakka56y@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.
-
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? -
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. -
twgerber26yI use to fight some of these minor standards years ago. I got beaten into submission ;)
-
@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.
-
@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 ;)
-
edwardcjk966yWait 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 -
@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
-
@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.
-
@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.
-
@gnulinuxer4fun i am a storywriter in camouflage. I should really cut it down though :/
-
@CodeMasterAlex Thanks man much appreciated, and good luck completing your assignment :)
-
funkyboss696y@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. -
@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
-
@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" -
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 -
Semmel946y@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?
the coding standard at my new company
#FML
rant