+ 9

I see a lot of newbies here who don't format their code properly 📣 summary of rules of coding style 📣

This is kind criticism :) I've been criticized for this too and it does have a meaning to write your code nicely. It is very important to do it same way all over your code, it increases readability not only for your peers but also for yourself, what if you want to come back to your code in two months? Will you still understand it? So here is a post for some common rules in programming languages or one specific programming language: Feel free to add something :)

12th May 2017, 6:06 PM
‎ɐısıօլɐ
‎ɐısıօլɐ - avatar
10 ответов
+ 17
I mark this thread, because i am simply obsessed to the style and the readability of my code... i still don't know if i should use this style: function (parameters) { . . . } or this: function (parameters) { . . . } And maybe i will never choice it. Btw, i think that more readability is fundamental not just for the coder, but for people that see your code! An Open Source code should be more readable possible. My tips: • Use the comments only when are necessary... i mean, do something like this... var dog = "Bob"; //Dog ... is useless. • Don't write all codes inline... if you have a simple if condition, it's okay... but for long statements, separate the codes in more lines for a better readability. • Be coerent with your style, if you choice a style in the top of your code, end that code with the same style. • Read this: https://en.m.wikipedia.org/wiki/Indent_style?wprov=sfla1 〰〰〰〰〰〰〰〰〰〰〰〰〰〰 There is not a rule to follow, you can choice style that you prefer, often people are polemic about the style of codes and (for my opinion) they are wrong... important is coherence with your code, and... if you make an Open Source code, you must to know that your code will be seen from other people. 〰〰〰〰〰〰〰〰〰〰〰〰〰〰 Yah, if my English is wrong, my apologies. =^=
12th May 2017, 6:41 PM
Maz
Maz - avatar
+ 11
@Maz That's for yourself :) Use functions and loops instead of hardcodes ;)
14th May 2017, 8:54 AM
Gami
Gami - avatar
+ 10
@Maz It was meant to be kind like a joke... Of course it is for everyone :))
14th May 2017, 9:11 AM
Gami
Gami - avatar
+ 9
Avoid nested code and use functions instead!
13th May 2017, 8:55 AM
Tim G
Tim G - avatar
+ 9
@Gami that's for all people that want to write better codes, in this period i'm focus on the clean code using functions, you inspired me to write less code for the same result. Anyway, my tips are not related with your comment, i wrote about the comments, the code inline and the { } religion, btw, thank you. ^^
14th May 2017, 8:58 AM
Maz
Maz - avatar
+ 8
Reminders: First: You might change your habits over learning to code, but you should slowly stick to certain patterns in your code. If you use a 4 spaces tab, don't do only 2 spaces somewhere else in your code Second: You still should preserve some adaptability, when you start working for a company, they might have their own rules and you have to stick to them
12th May 2017, 6:10 PM
‎ɐısıօլɐ
‎ɐısıօլɐ - avatar
+ 6
Quoted from the Oracle website: Four spaces should be used as the unit of indentation. The exact construction of the indentation (spaces vs. tabs) is unspecified. Tabs must be set exactly every 8 spaces (not 4). Line Length Avoid lines longer than 80 characters, since they're not handled well by many terminals and tools. Wrapping Lines When an expression will not fit on a single line, break it according to these general principles: Break after a comma. Break before an operator. Prefer higher-level breaks to lower-level breaks. Align the new line with the beginning of the expression at the same level on the previous line. If the above rules lead to confusing code or to code that's squished up against the right margin, just indent 8 spaces instead. Here are some examples of breaking method calls: For more, go to: http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-136091.html
12th May 2017, 6:27 PM
‎ɐısıօլɐ
‎ɐısıօլɐ - avatar
+ 4
Thank you, @Maz, for your contribution, this is sure helpful :D
12th May 2017, 6:43 PM
‎ɐısıօլɐ
‎ɐısıօլɐ - avatar
+ 1
what is your problem, @melo? :) we're here to help you
14th May 2017, 9:14 PM
‎ɐısıօլɐ
‎ɐısıօլɐ - avatar
0
I need soo much help help me!!
14th May 2017, 7:24 PM
melo