What is Hard Coding?
Hard coding is the practice of embedding specific values or configurations directly into a program or script, rather than using external sources for these values. Hard coding can be used for a variety of purposes, such as setting default values, defining constants, or specifying configuration details.
Hard coding has the advantage of being simple and easy to implement, but it can also have a number of drawbacks. One major issue with hard coding is that it can make it difficult to modify or update the values or configurations that are hardcoded into a program.
Why is this an issue?
Hardcoding the instance name can make it difficult to use scripts or applications with different instances or if the instance name changes.
It can be time-consuming and error-prone to modify hardcoded instance names when moving scripts or applications between instances.
Hardcoding the instance name can make it more difficult to manage and maintain scripts and applications, as they will need to be updated if the instance name changes.
A example of hardcoding your instance name would be:
1 2
// Hardcoded instance name var myInstanceName = "coda-instance";
How do I fix it?
Instead of hardcoding the instance name like this, it is generally better to use the System Property named instance_name
.
1 2 3 4 5 6
// Dynamically getting the instance name var instanceName = gs.getProperty("instance_name"); // Once the instance name is stored in the variable, you can use it in different settings without having to update the script gs.info(instanceName); gs.print(instanceName); gs.log(instanceName);
This allows the instance name to be changed easily, without the need to update the script.