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:
- Sidestepping the assignment negates its purpose. You fail to learn a concept or demonstrate your ability.
- In an academic setting, you simply fail.
- 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…
That is all.
Related posts: