Code quality – best practices
As stated earlier in this chapter, what we focus on here is the quality of the code, not the quality of the user experience when using our applications.
When writing code, there are some things we can keep in mind to make our code better, quality-wise.
We will look at some best practices and talk about why it is a good idea to use them.
Limiting line length
Long lines are never a good idea. Look at any newspaper and think about why the text hardly ever runs on one line across the full width of the page:
A rule of thumb is that if the line is wider than what can fit on the screen, then it is too wide. Use your common sense and divide the code into several lines if needed, but do so in a way that makes sense.
Take a look at the following screenshot. The code shown here is just one single statement and...