Hard coding: Difference between revisions

Content deleted Content added
Fixed spelling.
Tags: Mobile edit Mobile web edit
add ref
Line 1:
{{redirect|Hardcoded|the video game|Hardcoded (video game)}}
{{Multiple issues|
{{essay-like|date=July 2011}}
{{unreferenced|date=April 2007}}
}}
 
'''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|recompiling]] the executable, although it can be changed in [[Volatile memory|memory]] or on disk using a [[debugger]] or [[hex editor]]. Data that are hard-coded usually represent unchanging pieces of information, such as [[physical constant|physical constants]], [[Version number|version numbers]] and static text elements. [[Softcoding|Softcoded data]], on the other hand, encode arbitrary information like [[user input]], HTTP server responses, or configuration files, and are determined at runtime.
 
==Overview==
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–}}</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 which results from its usage within software design and implementation.
Line 56 ⟶ 52:
 
In rare cases where the possible number of inputs is small enough, a contestant might consider using an approach that maps all possible inputs to their correct outputs. This program would be considered a hard-coded solution as opposed to an [[algorithm]]ic one (even though the hard-coded program might be the output of an algorithmic program).
 
==References==
{{reflist}}
 
[[Category:Anti-patterns]]