A warning to commitment phobes.
You’ve spent hours upon hours, and days upon days working on your project. You’ve wrote many lines of code and finally, you think it’s ready to go. You compile and run, then all of a sudden, it doesn’t work. Whether it’s an error, or just nothing happens, you sit there flabbergasted. All that time, you created something that doesn’t even work. Where do you start? There are so many functions you wrote and debugging bit by bit could take forever, but what can you do?
My first big project in my first programming class was so much larger than all of my other assignments. Instead of writing one function, only several lines of code, I was writing multiple functions, all connected. I was making a small game in python and while I included some print statements to do some tests, I really just kind of ran with it. I took all the knowledge I had on what I should do, slapped it altogether, hit run, and nothing. I panicked, this project was due soon and it did not pass most of the tests.
What could have saved me the extra hours of rebuilding and fixing my program? Testing more frequently would have helped, but also committing. I had created a repository in github, but instead of using github to my advantage, I just worked on my project locally.
Had I used github, after completing a function, I could have run some tests, made sure it worked, and then committed and pushed my code. By committing and pushing to my github repository, I would have had a version of my program that worked up to that certain point. If I kept adding to my program and it stopped working, it would help with problem solving in two ways.
- I would know where to start looking.
My project was working the last time I committed and pushed, so there is a good chance the problem is between my last commit and this current one. I can start my focus on debugging the new code, rather than just starting at a random spot. - If nothing is working and I can’t find a solution, I can go back.
By testing and committing often, I would have a working program at different stages of development. If I wasn’t able to figure out the problem, I would be able to go back to a previous commit where things were working. This means not starting at ground zero and saving some time.
With coding it can be easy to get in the zone, but remember to commit and commit often. It can save you in the long run.