How to avoid errors while codding ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to avoid errors while codding ?

21st May 2019, 9:29 AM
Jaspreet Singh
Jaspreet Singh - avatar
7 Answers
+ 8
Avoiding is hard. For limiting them I personally find it helpful to code and test a few lines at a time. If you write too long a piece of code in one run, let's say 100 lines, just hoping it will work, in the likely case it doesn't work you'll have to figure out the mistake reading 100 lines. That will take eternally. So, in your mind or on paper, partition the tasks into little sub-tasks that will each only need a few lines. Write each mini task and test it until you're sure it does what it's supposed to. Only then write the next bit. Put the tasks into functions/methods. You test for them returning the right value for every argument you pass. If they do, when you write the other functions/methods, you can rely on the formerly written ones.
21st May 2019, 11:34 AM
HonFu
HonFu - avatar
+ 16
It only comes with years of experience. But even if you are a professional programmer, you can't foresee all different scenarios. Something can easily pop up. Great example: I watch some YouTube videos where highly experienced programmers do live-coding. Sometimes their apps / programs stop working as expected. And they spend some time trying to find this silly bug that ruins everything.
21st May 2019, 6:41 PM
Igor Makarsky
Igor Makarsky - avatar
+ 7
By gaining experience, making mistakes in the first place but learning from them will help you minimize your errors in the future.
21st May 2019, 9:30 AM
Sonic
Sonic - avatar
+ 4
Learn to write good unit testing using tools like Jest, Mocha, Pupperteer
21st May 2019, 9:34 AM
Calviղ
Calviղ - avatar
+ 4
make practice man perfect so, try to write programs as much as possible. and one your error completely vanished
21st May 2019, 3:58 PM
Ameer Wajid Ali
Ameer Wajid Ali - avatar
+ 2
Breakpoints
21st May 2019, 12:23 PM
HNNX 🐿
HNNX 🐿 - avatar
0
can you name same good youtubers from where we can learn how to code
22nd May 2019, 6:44 PM
Ayu_devil