Hard code

Hard-code refers to the software development practice of embedding data directly into the source code of a program or other executable object, instead of obtaining that data from external sources such as a configurations file or command-line parameters.

Considered a deprecated practice by most practitioners of the software art, it requires that the program code be changed any time that the data changes, when it might be more convenient to the end user to change the detail by some means outside the program.

For example, a hard-coded reference to a computer file would point to a specific file in a specific location on disk. If the file's location changed, the program code itself would have to be changed to find the file in the new location. An indirect reference, such as a variable inside the program called "FileName", could be expanded by accessing a "browse for file" dialogue window, and the program code would not have to be changed if the file moved.

Hard coding is especially problematic in preparing the software for translation to other languages.

Hard code is generally considered an anti-pattern.

See also: Hard code, Anti-pattern, Computer file, Disk, Program, Source code