Is there a specific term to call the process of modifying hard-coded codes into soft-coded codes? I have to report what I am doing to the Project manager, shall I just put “modifying hard-coded codes into soft-coded codes”?
Example of “hard-coded codes”
int random(){
return 42;
}
Example of “soft-coded codes”
int random(){
return Random.nextInt();
}
hard coded codes might fulfill requirements for a set of inputs, but it is not flexible.
EDIT: Accepted as Code Refactoring.
4
It depends on whenever you are changing behavior of the program as a whole. If you are changing a behavior then it is either “Bug Fixing” or “Adding a new feature”. In your example, random
always returning 42 could be considered bug so replacing it with Random.nextInt()
is fixing this bug. On the other hand, if you are replacing hard-coded values with values that are supplied from the outside. For example replacing hard-coded values with values read from config file is adding new feature of being able to configure the software from the outside.
On the other side, if you are not changing behavior of the program and just cleaning up the code, then that is called Refactoring. And it is generally done to increase quality of code without changing what the program does.
3
It is called “binding time.” So, the contrast is between early binding and late binding. If you hard code a number then you bind very early in the process; if you load the number from a file at run time, you are late binding. In general, the later you bind, the easier the code is to test and maintain.
Here is a good discussion: http://en.wikipedia.org/wiki/Late_binding