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
-
That's fine for classes. Methods/loops/if-statements/etc on the other hand...
#OneTrueBraceStyle -
@Christine well it's fine but i prefer the 2nd style. i guess in the end it's just a matter of style taste :)
-
RYPTAR13268y@linuxxx Seriously, so much easier to read through code. Now I will say if statements with a single line of indented code w/o braces are the shyt
If(true)
++Vote; -
brahn15748yAre you trying to start a war?
Let's just go with "whatever the coding standards for your team says" and try not to take the discussion too far. -
What's wrong with war?
Everyone will emerge more close to nirvana and increase in knowledge.
Best way to learn tbh.
So bring your points sonny.
ps: this is dev community, so don't let me tell you to be logical and not emotional hissy cat.
BEGIN. -
I tend to use the second for js and the first for C#/backend languages. I only backed down on js as a lot of the linters/formatters tend to go for the same line braces style. I do agree with your teacher though that the first is more readable as a code block and gives you good spacing and you can turn on indentation lines which visually links opening and closing brackets and makes it look even neater and easier to see what belongs to what.
-
STRINIX1578yIm always using the first option cuz thats what visual studio does by default (programming C#). I prefer the second though but whatever i guess
-
I prefer the first style as it is easier to see the blocks when you're browsing through the code.
Ultimately though I like how python does it. -
@querellaMMXII that's exactly what my teacher said... well, i've never even tried to use that style because i don't work and haven't been restricted by team coding standards, i just code for myself and classes, where they don't care about the coding style.
-
Grumpy28878yOne of several advantages of programming in F#, Haskell etc is that you get to say "Curly braces and semicolons are sooo 80's".
-
@brahn Honestly yeah. I too have strong opinions on how I prefer code to be formatted, but honestly, I stopped giving much of a shit once IDEs started taking care of formatting for me.
-
zeroth98yFor some time I used the second one exclusively and find the first very ugly. But I had to change because the work standards, than I got used to that. Today i have no problem with either. 😀
-
timurtu578y@RYPTAR I hate those because you see them in huge files and people squeeze them on one line. I think adding the curly braces even just for one line is way more readable
-
timurtu578yThe worst is when people put it all on one line curly braces and all
function foo() { console.log('bar') }
No it doesn't make you a better programmer to put things on one line that shouldn't be -
f03n1x65808yIt's a style that you should have the choice to choose I use brace per line but worked with a friend who had first brace on the first line, he tried to justify the choice and honestly I didn't care lol, I chose to use one way, like I choose to use m_variableName with globals, though that is more to do with a lecturer I thought was awesome uses the same concept.
Just do what you want really as long as it's readable and not on one line should be fine. -
Wombat105828yI like the first one more because it's more readable. I still use the second but only in JS for events.
-
-eth18618yI prefer the first style, since with code folding I don't get hanging open curly braces every line
-
yes, a year later i came here to say that i'm writing the first style now and i like THAT now. sorry not sorry ¯\_(ツ)_/¯
Related Rants
-
xjose97x19Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
elgringo41Student - Teacher renaming .c to .exe make the program executable ? Teacher - Yes A group of people stand up...
-
Cyborg15A guy and a girl are in a Java seminar. Afterward, the guy approaches the girl and asks, "Hey gurrl, can I ge...
when your teacher says he prefers this:
class A
{
// code
};
over this:
class A {
// code
};
me: can u not
undefined
oop
c++
teacher