Softcoding is a
computer coding
Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programming involves tasks such as anal ...
term that refers to obtaining a value or function from some external resource, such as
text files
A text file (sometimes spelled textfile; an old alternative name is flatfile) is a kind of computer file that is structured as a sequence of lines of electronic text. A text file exists stored as data within a computer file system. In operating ...
,
INI files,
preprocessor
In computer science, a preprocessor (or precompiler) is a program that processes its input data to produce output that is used as input in another program. The output is said to be a preprocessed form of the input data, which is often used by s ...
macros, external constants,
configuration file
In computing, configuration files (commonly known simply as config files) are files used to configure the parameters and initial settings for some computer programs. They are used for user applications, server processes and operating system ...
s,
command-line
A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive command (computing), commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invokin ...
arguments, databases, user input, HTTP server responses. It is the opposite of
hardcoding
Hard coding (also hard-coding or hardcoding) is the software development practice of embedding data directly into the source code of a program or other executable object, as opposed to obtaining the data from external sources or generating it at ...
, 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 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
An anti-pattern in software engineering, project management, and business processes is a common response to a recurring problem that is usually ineffective and risks being highly counterproductive. The term, coined in 1995 by computer programmer An ...
. 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
The Daily WTF (also called Worse Than Failure from February to December 2007) is a humorous blog dedicated to "Curious Perversions in Information Technology". The blog, run by Alex Papadimoulis, "offers living examples of code that invites the ex ...
.
Softcoding
from The Daily WTF
The Daily WTF (also called Worse Than Failure from February to December 2007) is a humorous blog dedicated to "Curious Perversions in Information Technology". The blog, run by Alex Papadimoulis, "offers living examples of code that invites the ex ...
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.
The boundary between proper configurability and problematic soft-coding changes with the style and nature of a program. Closed-source programs must be very configurable, as the end user does not have access to the source to make any changes. In-house software and software with limited distribution can be less configurable, as distributing altered copies is simpler. Custom-built web applications are often best with limited configurability, as altering the scripts is seldom any harder than altering a configuration file.
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
A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled.
A scripti ...
. 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
Feature may refer to:
Computing
* Feature (CAD), could be a hole, pocket, or notch
* Feature (computer vision), could be an edge, corner or blob
* Feature (software design) is an intentional distinguishing characteristic of a software item ...
, softcoding has other meanings.
* Hardcoding
Hard coding (also hard-coding or hardcoding) is the software development practice of embedding data directly into the source code of a program or other executable object, as opposed to obtaining the data from external sources or generating it at ...
: feature is coded to the system not allowing for configuration
* Parametric: feature is configurable via table driven, or properties files with limited parametric values
* Softcoding: feature uses “engines” that derive results based on any number of parametric values (i.e. business rules in BRE
British English (BrE, en-GB, or BE) is, according to Oxford Dictionaries, "English as used in Great Britain, as distinct from that used elsewhere". More narrowly, it can refer specifically to the English language in England, or, more broadly, ...
); rules are coded but exist as parameters in system, written in script form
See also
* Self-modifying code
In computer science, self-modifying code (SMC) is code that alters its own instructions while it is executing – usually to reduce the instruction path length and improve performance or simply to reduce otherwise repetitively similar code ...
* Inner-platform effect
The inner-platform effect is the tendency of software architects to create a system so customizable as to become a replica, and often a poor replica, of the software development platform they are using. This is generally inefficient and such syste ...
* Rule of least power
In programming, the rule of least power is a design principle that
"suggests choosing the least powerful omputerlanguage suitable for a given purpose". Stated alternatively, given a choice among computer languages, classes of which range from ...
References
{{reflist
Computer programming
Anti-patterns