Search This Blog

Sunday, March 21, 2010

Chapter 6: Writing High-Quality Code

High-quality code is code that works well, works efficiently, is well documented, is easy to debug and maintain, and is also easy for others to work with. But because there are many different ways to code applications and produce the same functionality, you may end up working with code that does the job, but is poorly written and therefore hard to maintain.


Establishing and following a formal development process can be a pain (especially if you're used to seat-of-the-pants programming), but it helps produce high-quality code and is essential for the success of larger projects. And although some differences in coding style are to be expected, and perhaps even encouraged, using a consistent approach (as defined by a coding standard) brings great benefits, especially when building larger projects within an organization. Using a coding standard, such as the ones discussed in this chapter, is a vital part of high-quality code.


Another gauge of high-quality code is how well it is structured. Functions and include files should be used whenever you are performing the same processing, or nearly the same, in multiple locations in your program, simply because using them means only having to modify the code in one place, rather than many. These indicators are among those discussed in this chapter that can guide you in writing first-rate code.


In Chapter 5 you discovered how to make your code more graceful handling errors, more secure, and more efficient. In this chapter you continue along the path to quality code by learning about coding standards and the use of functions, objects, and include/require statements. You'll also review development processes and learn how to optimize your code. As you can tell, there's a lot of work involved in creating high-quality code, but you won't be sorry—it'll be well worth your effort.