// you’re reading...

Contests

hard code

Hard coding is the practice of embedding a pre-calculated result into a program. Input is disregarded, there are no calculations or logic flow, just unchanging (thus “hard”) output. This shouldn’t count as programming. And even though hard code is appropriate sometimes (such as stubs in test suites), it is most often encountered in a matter of avoiding doing real work.

This makes me recall one of my all-time favourite programming webcomics from MacHall:

you miserable monkey men who tried to hardcode the results are beneath my mention

As a person controlling your (DWITE) grades, I too have some advice:

  1. Sidestepping the assignment negates its purpose. You fail to learn a concept or demonstrate your ability.
  2. In an academic setting, you simply fail.
  3. You are almost there. Even the hard code values come from somewhere, perhaps from figuring things out on paper — put the same logic into the program.

Though I think I’ll let MacHall offer the final advice on writing hard code…

work harder or there'll be hell to pay

That is all.

Read more

Discussion

  1. Posted by Nick | February 21, 2008, 1:02 am

    I remember a year ago (when I first started programming) all I knew how to do was hardcode. Looking back at my own code really makes me wonder what was going through my mind. I remember looking at my code for a Tower Defense game I had once witten, it was so horrible I could barely keep reading. Now though I still do hardcode when writting a large project but once I fininsh writing the part I’m writing I always go back and soft code it if you will. I find it’s much easier if it’s not hardcoded in the end.

    Reply to comment

Post a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>