Coding best practices
When scripting, there are many ways to achieve the same goal, but keeping code efficient can make it much easier to maintain and work on in the future. Using a few system resources is usually encouraged too, as this decreases loading times and the load on the data center in the cloud.
You will often find that older instances suffer from poor performance because best practices were not adhered to during development. I have been part of minor projects simply to make code more efficient before, and because these are often associated with slow loading times, it can be a great improvement for the user base.
In this section, we will look at how to make sure your script adhers to best practices and how to avoid common mistakes.
First, one type of scripting that is quite common is nested if
statements. This is an if
statement after an if
statement and is often used to catch several potential values for the same variable. We can see a server-side example of what this looks like...