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:
As a person controlling your (DWITE) grades, I too have some advice:
Though I think I’ll let MacHall offer the final advice on writing hard code…
That is all.
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