+ 4

Good coding practices

I'm a biologist. Got my Master in Zoology studying wildcats (ocelots and jaguars). Started to use databases to store and analyse camera traps data (cameras with movement sensors we fix in the forest to take pictures of animals). Now I'm a PhD candidate in Ecology and use R for stats combined with markdown and SQL for dbases. Nevertheless, as I never had a formal backgroung, I stil strugling in generate nice decent codes. Would you indicate a "good coding practices for totally dummies"? Cheers

20th Jan 2018, 11:39 AM
Fernando Lima
Fernando Lima - avatar
5 Respuestas
+ 7
I usually work the algorithm out on paper first -- kind of as a "proof-of-principle", to make sure that the idea can even be done. This step involves doing anything you can to get going: math tables, flow charts, researching textbooks, etc. This is where most of the blood, sweat & tears should be shed. After you get some sort of description of what should happen, then you can create a quick pseudo code version on paper (don't worry about syntax yet). This is where you figure out the best strategies for the code: which loops, decision blocks, variable tactics, classes, etc, etc, to use, how and why. If the pseudo code looks half decent, go ahead and type it in. It's good if your IDE or SDK has a line-by-line interpreter to catch all the syntax errors, which you can fix right away, instead of waiting for compile time. If the programme compiles, you can then run it. Debugging the logic is the next bit of Pergatory to go through. Be aware of errors which will compile but are logically wrong, such as if (x = 1). This is assignment, whereas you actually want comparison or truth testing: if (x == 1). Don't worry about having many debugging cycles; I rarely write a programme which goes through without any problems at all. And don't ever give up!
21st Jan 2018, 3:52 PM
Eric Zatarack
Eric Zatarack - avatar
+ 2
wow..love ur work ...well as a beginner try to have time for learning and practicing
20th Jan 2018, 12:47 PM
Android Boi
Android Boi - avatar
+ 1
I wish I could give it more than one upvote! many thanks for your insights! It gave me more info than dozens of videos, foruns and texts!
21st Jan 2018, 10:04 PM
Fernando Lima
Fernando Lima - avatar
+ 1
The best practice is to simply code. Try to find some small challenge that will test your coding knowledge.
24th Jan 2018, 9:54 PM
Purpll
Purpll - avatar
0
Python is best i just beginner in programming and it is fucking easy and fun to program here.
20th Jan 2018, 11:49 AM
Umar Igan
Umar Igan - avatar