Re: learning to code
This may not seem important at the time, but it truly is an incredibly helpful thing - it allows you to not only "explain" your code to someone else but also allows you to recall later on how you solved a particular problem or how your output was coming about. Logic (once you get used to it) may make sense to you one day when you're slaving away at making something work how you want it to, but when you come back to it you could be looking at it like you are reading Greek. I coded a battleship program in C++ and the "AI" I was developing was not overly intuitive. I didn't bother commenting well the first time through, and the next time I went in to work on it and debug something for an issue I was having, it was a nightmare. I had to essentially re-learn the process I was using.
I do this all the time. If you think you should be getting a certain output and you're not, trace through piece by piece and gather your expected output and behavior at each point. Once you've done that, add in catches or change minor things to test or display your output along the way, allowing you to see where things went wrong if they weren't popping out to you before.
This is probably my #1 used thing when writing new code on something. If it's a simple project that uses concepts I already know I may dive into writing code, but almost 95% of the time I am going to actually start by writing "pseudo-code", or paraphrased steps of what I need to accomplish to reach the goal. You absolutely want to break this down to the smallest pieces for every step along the way, and over time you'll be able to start filling things in with code (ie I need a variable for this, or I need to loop through a function for this outcome, etc).
Best of luck with things. Practice really does make perfect.
This may not seem important at the time, but it truly is an incredibly helpful thing - it allows you to not only "explain" your code to someone else but also allows you to recall later on how you solved a particular problem or how your output was coming about. Logic (once you get used to it) may make sense to you one day when you're slaving away at making something work how you want it to, but when you come back to it you could be looking at it like you are reading Greek. I coded a battleship program in C++ and the "AI" I was developing was not overly intuitive. I didn't bother commenting well the first time through, and the next time I went in to work on it and debug something for an issue I was having, it was a nightmare. I had to essentially re-learn the process I was using.
I do this all the time. If you think you should be getting a certain output and you're not, trace through piece by piece and gather your expected output and behavior at each point. Once you've done that, add in catches or change minor things to test or display your output along the way, allowing you to see where things went wrong if they weren't popping out to you before.
This is probably my #1 used thing when writing new code on something. If it's a simple project that uses concepts I already know I may dive into writing code, but almost 95% of the time I am going to actually start by writing "pseudo-code", or paraphrased steps of what I need to accomplish to reach the goal. You absolutely want to break this down to the smallest pieces for every step along the way, and over time you'll be able to start filling things in with code (ie I need a variable for this, or I need to loop through a function for this outcome, etc).
Best of luck with things. Practice really does make perfect.









To re-emphasize what everyone else said, it's important to think about how you want to code the solution before jumping in and realizing halfway through that it doesn't work and you have to start over again. One of my professors used to recommend about 50/50 ratio for planning/implementing, and from experience I pretty much agree give or take depending on the problem, because usually if you design or do pseudocode correctly, implementing isn't too bad.
Comment