hard codedProgramming code that solves a problem, but offers little flexibility for future modifications. Hard coding could be thought of as "brute force" programming: it gets the job done. However, the degree to which a program is hard coded determines how difficult it is to change with each new type of data that is introduced or each new function that is added.
Because It Is Easier
Very often, the processing is hard coded in the first release of an application and generalized later. The reason is simple. It is always easier to hard code a solution than to write a generalized routine that handles a variety of possibilities.
Hard Coding Vs. Hand Coding
While hard coding and "hand coding" sound somewhat similar, they are not. Hard coding refers to writing a fixed solution rather than a generalized one. Hand coding refers to writing the program in a programming language rather than a high-level GUI-based tool. See hardwired, hand coding, generalized program and data independence.
Fixed Vs. Variable Example
In the following very simple pseudocode example, it takes half as many lines of code to write a program that bounces a ball 10 times (fixed task) rather than a variable number of times:
Hard Coded (10 times) start 1 ballCount = 0 loop 2 bounce ball 3 add 1 to ballCount 4 if ballCount = 10 5 stop else 6 goto loop Flexible Code (variable number) start 1 display "Enter Bounce Count" 2 input to maxCount 3 if maxCount not an integer 4 display "Not a valid number." 5 goto start else 6 ballCount = 0 loop 7 if ballCount not = maxCount 8 bounce ball 9 add 1 to ballCount 10 goto loop 11 else 12 stop