A Single Article

Read it, comment, and share it with your friends

Something I learned after long nights of coding

Posted October 30 in Technology.

I just spent the better part of the period between last Thursday and yesterday rewriting a major project for my “Optimizing Compilers” course. Here’s the lowdown:

  • For projects 2 through 6, each project builds upon the previous one. You use the same code and it simply grows from one project to the next.
  • The professor never, ever releases solutions to past projects.
  • We program in C, which is really really hard.

My partner and I went through the past couple projects (we are on #4 right now) just trying to complete them however possible. We basically ended up doing things the wrong way… our code was very iterative, did not use very many of the functions that the professor provided, and was horribly bloated. Sometime last week I realized that we had serious errors in the results that our compiler was producing, and I decided that there was no way to fix the code other than going back to the start of project 2 and rewriting everything the correct way. At first I tried avoiding this course of action, but I then went with my gut instinct and started fresh from the beginning.

It took at least 20 hours of my partner and I working together to figure out how the professor’s functions worked, develop the algorithms for doing everything recursively where the professor intended for it to be done, and figure out which of our functions could be reused and which had to be discarded. It was really tough… while most Cornell students were out partying Friday and Saturday night, my partner and I were in the Linux lab coding into the following mornings. I guess this is where Cornell has taught me how to really get into my work and grind away until it’s done. Ugh. I don’t care to have skills like that.

As you can probably guess, we did manage to catch up with the current project, and our new code is much cleaner, and more importantly, more correct than what we had before. All the work was worth it. We might even be able to finish project 4 (it’s due Wednesday).

Last night, while walking back to my dorm from the lab at a very late hour, I was thinking about this experience and a similar one in my Computer Architecture course. I realized two things always seem to be true about programming:

  • There is always an elegant solution to every problem, one which is clean and simple and works amazingly well.
  • When you have lots of bugs and can’t seem to fix your code, it’s usually a good idea to start over, knowing that the knowledge you’ve gained from your hours of work will most likely enable you to correct your mistakes and find those elegant solutions.

Have you observed this in your programming projects? Have you ever started over from scratch and found it to be a wise choice?

Update 11-2-06: Just wanted to let you know that I (sort of) finished the project. It took all of my time in the past week, including staying up all night last night in the lab working on it (I didn’t sleep at all), and in the end I had an implementation that fulfilled the requirements almost entirely. I did, however, have a bug in our code that I was never able to solve, but hopefully it will go unnoticed when the grader tests it. Here’s looking to the next step of the project, due 2 weeks from now :)

Meta

Useful things

Check This

and support what I do
Future of Web Design 2008

Related Articles

These just might ring a bell

Get a Trackback link

1 Trackbacks/Pingbacks

Other blogs referencing this article
  1. Pingback: I Have Senioritis - Episode 9: The late late show on October 30, 2006

2 Comments

Responses to my article
  1. Chris H. October 31, 2006

    Two years ago when I was learning C++, one of the projects involving operators and functions brought me to a bind, a roadblock in the wonderful, mythological world of the programming world. This was one of those final projects you had to do, and if you wanted to get a double A exception for taking the final exam, I just needed this project to get me a 90%; what can one do? It’s high school computer science courses; I’d rather spend time surfing the Internet in programming class than stressing over reminiscing on everything C++ on that exam. Over the course of the week, I couldn’t figure out how to get the program to output as it would on the program specifications sheet.
    So, in the end, I just scrapped the project, and started all over again. I kept the old code as a reference as what not to code, and probably somehow have a small light of gleaming hope that the program would output the results correctly. Since I scrapped the code so late in the week, the project was due that Friday, I scrapped it on Thursday, I had to stay after class, and whenever I had to a chance, to code like there was no tomorrow. On the contrary, it wasn’t until late in the afternoon, on the last day the project was due, that I finished the project, it worked; but it wasn’t completely bug-free. Had I more time to finish the project, it would have been better and cleaner.
    It was good times, now I have to pick up on C# soon. :P

  2. FoxyLady November 1, 2006

    Have you observed this in your programming projects? Have you ever started over from scratch and found it to be a wise choice?

    From the cruel experience that was CS100 in freshman year, I’ll say, “NO.” My projects never got better the second time around. I’m just glad I had the foresight to choose a major with such little programming involved.

Leave a comment

Share your thoughts with the world

You can use Markdown, or you can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Please keep comments respectful and on topic.

This form is guarded by Akismet, so don't waste your time trying to submit spam. It won't work. Ever.





Stay on top of new updates at this site: Subscribe to the Feed!