+ 9
How do i do to write cleaner code? Can you give me some tips to write more cleaner code?
5 odpowiedzi
+ 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.
+ 23
if you didn't find John Wells, here 2 codes from him
https://code.sololearn.com/cXLsoz2aY4TC/?ref=app
https://code.sololearn.com/cdS29QxVDQQJ/?ref=app
+ 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 👍😉
+ 7
https://www.codeschool.com/blog/2015/09/29/10-ways-to-write-cleaner-code/
refer this link it will help you
+ 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