Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
Softcoding is the programming practice of obtaining values from external sources, such as preprocessor macros, external constants, databases, command line arguments and user input. The term is the opposite of "hardcoding," or putting values directly in the source code, unable to be changed by users. Softcoding is considered more flexible.
In programming, hardcoding, or directly embedding configuration data in source code, is considered bad practice because it makes software difficult to configure. It is considered better practice to obtain values from external sources, such as configuration files or command line arguments. This is called "softcoding."
The obvious advantage of softcoding is that it is much easier to change parameters with user input than it is by going into the source code. At the same time, it is possible for developers to go overboard, abstracting too many elements so that the software becomes more difficult to maintain, negating the goal of softcoding. Other times, they might create poorly designed scripting languages.
It is better for developers to examine the needs of individual software projects. With a small in-house tool or open-source program, developers can assume that people will have access to source code and can make changes, meaning that the program can be less configurable. A proprietary program would need to be more configurable, since users are not able to change the source code.