Softcoding
   HOME

TheInfoList



OR:

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 an ...
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 line (text file), lines of electronic text. A text file exists Data storage, stored as data within a com ...
, 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 so ...
macros, external constants,
configuration file In computing, configuration files (commonly known simply as config files) are computer file, files used to configure the Parameter (computer programming), parameters and Initialization (programming), initial settings for some computer programs. T ...
s,
command-line A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and pro ...
arguments, databases, user input, HTTP server responses. 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 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 scripting ...
. In many cases, the appropriate design is a
domain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. This is in contrast to a general-purpose language (GPL), which is broadly applicable across domains. There are a wide variety of DSLs, ranging f ...
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 * 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 Lexico, Oxford Dictionaries, "English language, English as used in Great Britain, as distinct from that used elsewhere". More narrowly, it can refer specifically to the English language in ...
); 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 d ...


References

{{reflist Computer programming Anti-patterns