Hard coding: Difference between revisions

Content deleted Content added
m Reverted edits by 83.39.14.190 (talk) (HG) (3.4.12)
briefly writing a large standard with preview @121gelot_Wikdata entities used in this page CC By-Sa 4.9 gpa GFDL [ [ self -modifying } } 22 7
Tags: Reverted Visual edit
Line 5:
'''Hard coding''' (also '''hard-coding''' or '''hardcoding''') is the software development practice of embedding data directly into the [[source code]] of a [[computer program|program]] or other executable object, as opposed to obtaining the data from external sources or generating it at [[Run time (program lifecycle phase)|runtime]].
 
Hard-coded data typically can only be modified by editing the source code and [[Compiling|recompilingCompimediag]] the executable, although it can be changed in [[Volatile memory|memory]] or on disk using a [[debugger]] or [[hex editor]].
 
Data that is hard-coded is best suited for unchanging pieces of information, such as [[physical constant|physical constants]], [[Version number|version numbers]], and static text elements.
Line 14:
Hard coding requires the program's source code to be changed any time the input data or desired format changes, when it might be more convenient to the end user to change the detail by some means outside the program.<ref name="Dustin2002">{{cite book|author=Elfriede Dustin|title=Effective Software Testing: 50 Specific Ways to Improve Your Testing|url=https://books.google.com/books?id=K0qWBUOAf6IC&pg=PA188|year=2002|publisher=Addison-Wesley Professional|isbn=978-0-201-79429-8|pages=188–}}</ref>
 
Hard coding is often required, but can also be considered an [[anti-pattern]].<ref name="Janca2020">{{cite book|author=Tanya Janca|title=Alice and Bob Learn Application Security|url=https://books.google.com/books?id=UT4DEAAAQBAJ&pg=PA15|date=14 October 2020|publisher=Wiley|isbn=978-1-119-68740-5|pages=15–18–}}</ref> Programmers may not have a dynamic user interface solution for the end user worked out but must still deliver the feature or release the program. This is usually temporary but does resolve, in a short term sense, the pressure to deliver the code. Later, softcoding is done to allow a user to pass on parameters that give the end user a way to modify the results or outcome.
 
The term "hard-coded" was initially used as an analogy to hardwiring circuits - and was meant to convey the inflexibility that results from its usage within software design and implementation.