display | more...

To hard code something is to program it in such way that it is permanent. The only way to change the object, value, whatever is to modify the source code. Generally, this kind of programming is to be avoided because it leads to code that is not reusable. Hard coding is often looked down upon as a sign of weak programming. Hard coding does have its place in however.

Soft coding, the flip side of hard coding, can be taken to an extreme. I for example was once told to soft code my hard coding of the value of PI 3.14 in a program. I was told to put in a variable that could be changed at runtime. This is good in case the value of PI should ever change. However, this is not likely to happen. My code would have been faster smaller and more readable had I been allowed to keep my hard coding of PI in. This is just one example of where hard coding is appropriate.

Log in or register to write something here or to contact authors.