Softcoding: Difference between revisions

Content deleted Content added
needs sections
Adding sections; removing tag
Line 1:
{{notability|Neologisms|date=May 2010}}
{{one source|date=May 2010}}
{{sections|date=February 2012}}
'''Softcoding''' is a [[computer programming|computer coding]] term that refers to obtaining a value or function from some external resource, such as a [[preprocessor macro]], external constant, configuration file, command line argument or database table. It is the opposite of [[hardcoding]], which refers to coding values and functions in the source code.
 
==Programming practice==
Avoiding hard-coding of commonly altered values is good programming practice. Users of the software should be able to customize it to their needs, within reason, without having to edit the program's source code. Similarly, careful programmers avoid [[Magic number (programming)#Unnamed numerical constants|magic numbers]] in their code, to improve its readability, and assist maintenance. These practices are generally not referred to as 'softcoding'.
 
The term is generally used where softcoding becomes an [[anti-pattern]]. Abstracting too many values and features can introduce more complexity and maintenance issues than would be experienced with changing the code when required. Softcoding, in this sense, was featured in an article on [[The Daily WTF]].<ref>[http://thedailywtf.com/Articles/Soft_Coding.aspx Softcoding] from [[The Daily WTF]]</ref>
 
==Potential problems==
At the extreme end, soft-coded programs develop their own poorly-designed and implemented scripting languages, and configuration files that require advanced programming skills to edit. This can lead to the production of utilities to assist in configuring the original program, and these utilities often end up being 'softcoded' themselves.
 
Line 14 ⟶ 15:
To avoid 'softcoding', consider the value to the end user of any additional flexibility you provide, and compare it with the increased complexity and related ongoing maintenance costs the added configurability involves.
 
==Achieving flexibility==
Several legitimate design patterns exist for achieving the flexibility that softcoding attempts to provide. An application requiring more flexibility than is appropriate for a configuration file may benefit from the incorporation of a [[scripting language]]. In many cases, the appropriate design is a [[___domain specific language]] integrated into an established scripting language. Another approach is to move most of an application's functionality into a library, providing an API for writing related applications quickly.
 
==Other meanings==
In [[feature design]], softcoding has other meanings.
* [[Hardcoding]]: feature is coded to the system not allowing for configuration