Which is your style of coding? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 41

Which is your style of coding?

Note for loop only contains 1 statement. i saw some people including me uses braces{} Even for 1 statement. Is it good practice? ---------------------------------------- Style 1: for(i=0; i<9; i++) s += i; ----------------------------------------- Style 2: for(i=0; i<9; i++){ s += i; } ------------------------------------------- Style 3: for(i=0; i<9; i++) { s += i; } --------------------------------------- My style is 2 in all case😅 post your style for single and multiple😆 Also tell which is best?

28th Jul 2017, 5:14 AM
Fuyuka Ayumi(冬花)
71 Answers
+ 25
2.
29th Jul 2017, 6:24 AM
Nithiwat
Nithiwat - avatar
+ 23
For very short statements, I just nest them directly into increment section, if it doesn't affect the result. for (i = 0; i < 9; s += i++); It's not a good practice, but lol. Highly influenced by SL challenges wts material.
28th Jul 2017, 5:57 AM
Hatsy Rei
Hatsy Rei - avatar
+ 17
style_2: all case for (i=0, i<9,i++){ s+=1; }
2nd Aug 2017, 5:30 AM
niteOwLTwO
niteOwLTwO - avatar
+ 15
1 or 2.
28th Jul 2017, 7:16 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 14
2.
28th Jul 2017, 5:47 AM
jay
jay - avatar
+ 13
2.
29th Jul 2017, 6:43 AM
Femyk
Femyk - avatar
+ 12
my style is 2
2nd Aug 2017, 4:05 AM
Niharika.R
Niharika.R - avatar
+ 11
5: for(i=9;i--;) s+=i;
28th Jul 2017, 6:17 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 11
#2
28th Jul 2017, 7:49 AM
Saori 劉
Saori 劉 - avatar
+ 11
I tend to write long codes so after I understand them well enough I reduce whitespace and line breaks... ie this style. for (i=0;i<99;i++){console.log(i);} otherwise style 2 almost always
28th Jul 2017, 8:37 AM
Russel Reeder
Russel Reeder - avatar
+ 11
mostly 1 and 2
28th Jul 2017, 9:49 AM
P R
P R - avatar
+ 11
Am in love with 2
29th Jul 2017, 8:04 AM
Krafty Coder
Krafty Coder - avatar
+ 10
I just try to squeeze as much as possible, unless I am noob at that language. Ao mostly I look like: for (i=0;i<9,i++){do stuff}
29th Jul 2017, 12:11 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 9
1 and 3
28th Jul 2017, 7:55 AM
aziz
aziz - avatar
+ 9
@JeMa=@Hatsy Rei {^_^}
29th Jul 2017, 1:36 PM
JΞΜΔ 🇨🇩👑
JΞΜΔ  🇨🇩👑 - avatar
+ 8
I do for(;;) ...; Another thing I do is if(){ ... }else if(){ ... }else { ... }
29th Jul 2017, 12:37 AM
Andrés04_ve
Andrés04_ve - avatar
+ 8
None because in python we dont use brackets 😁
29th Jul 2017, 1:52 PM
Anthony Perez
+ 8
Visual Studio has the default 3, so it's the one I usually use so I like the 2
31st Jul 2017, 3:34 AM
Paolo Torregroza
Paolo Torregroza - avatar
+ 8
@Prashant i think @XiangShuai is from US so he don't know hindi, try some translators or better learn English😊
6th Aug 2017, 2:22 PM
Fuyuka Ayumi(冬花)
+ 8
2
22nd Aug 2017, 2:06 PM
AL.The.Flame!
AL.The.Flame! - avatar