Can you all relate to the above image either while solving tough problems on LeetCode, GeeksforGeeks, some other websites, or working with projects?
Yes, we all are the same and it's the most common doubt among beginners or say codenewbie. I can relate to it and believe me or not it's becomes so demotivating to continue with same. When I was a beginner, thoughts often came to my mind that this programming sort of thing is not made for me, and thought of giving up.
After reading so many articles over the internet, I learned the correct way of learning and improving my productivity. Did I give up?
No, remember the most important rule of being a programmer:
Curious to know what to do in such conditions? Stay in the loop and I will help you with that.
These tips will be useful regardless of whether you are doing development or problem-solving.
But there is a famous rule in programming that says “never copy-paste code that you don’t understand”.
Confused? I am saying to break into someone's code but never copy them.
Well, you have there are few steps that you have to follow.
First try to understand the logic from it and try to code by yourself, if you can't then follow the below steps.
- Type the complete code by looking through it. (yes, yes, I know I just said not to do copy paste and now this, patience, patience).
- Make sure that your program or application is functioning as expected, i.e. confirm that block of code really did solve your problem.
- Delete the copy and pasted block of code line by line.
- Each time you delete a line, check to see what’s been broken. Does the app still run? What are the error codes? What has deleting that line of code done to your program?
- Even if you think you know what a line of code does, delete it any way. The most important task as a programmer is to always test your assumptions against the outcome. The most enjoyable feeling as a programmer is for the real world to validate your assumptions. You know how nice it is when your boyfriend/girlfriend/husband/wife says those magical three words. 0 Errors or All Testcases Passed or AC or I was right. It’s like that, but better.
By breaking the solution code, line-by-line, you’ll learn and understand what each line does and why it’s been written. This is a far better way to use code from other people than just pasting it in and hoping for the best. Once you understand why each of those lines was necessary, the next time you encounter a similar problem, you’ll be able to tease out the problem and solve it yourself.
You might now probably ask, ok I will follow these tips but how will I know if I have improved or not? What's my progress.
Well for that what you need is to bookmark the question or note down where your code was failing. Once you have took help from any source, come back after some time let's say 2-3 weeks and try to code now by yourself. Still can't? Continue this loop until you can solve without looking to solution.
This was how I get out of coding ruts.
Feeling confident and motivated now?
Yes, All the very best for your journey.
No? Feel free to reach out to me at my social handles @geeky01adarsh
Let me know your thoughts in the comment box below.