+ 9

How do i do to write cleaner code? Can you give me some tips to write more cleaner code?

7th Apr 2018, 7:43 AM
Rui Pedro Leocádio Borges
Rui Pedro Leocádio Borges - avatar
5 Réponses
+ 7
GAWEN STEASY good link, but there is something missing that I think is quite important for making code more readable: line length. I know that you could fit 200+ characters on a single line without the need for horizontal scrolling, but is it good to do it? Nope. You should only do this if it is needed (for example big strings to html addresses) and stick to about max 100 characters per line for your normal code. The reason is quite simple: When you read a text you want to read it from the top to the bottom. And not left end of the screen to the right end, to the left end, to the right end, and so on. You should read code like a book, not like an ad on a train. And what I also want to mention is that the main reason you should write cleaner code is maintainability. It's not just about variable/function names&scope, indention, etc., but also about design choices. But that's a bit too large topic. I guess you just asked for the looks of a code.
7th Apr 2018, 9:59 AM
Alex
Alex - avatar
7th Apr 2018, 9:16 AM
tooselfish
tooselfish - avatar
+ 19
hello rui pedro, have a look at the codes from John Wells, he created great clean codes with a good description! thats just my opinion 👍😉
7th Apr 2018, 7:54 AM
tooselfish
tooselfish - avatar
7th Apr 2018, 7:45 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 5
Yeah sure. Give space after each line. Don't let your variables be cluttered up everywhere in the code. Declare them at the start of the program, all together. I guess you will face no problem like this in Python or Ruby well. Give comments so the person understands what is being done in the code See some of my codes. I consider them clean and tidy. https://code.sololearn.com/cHD1Z4mg073N/?ref=app https://code.sololearn.com/cH7SKl2jq8GK/?ref=app
7th Apr 2018, 7:57 AM
Aaron Stone
Aaron Stone - avatar