Chapter 20. Writing High-Quality Code
If you've worked your way through the book thus far, you have a good grounding in the techniques needed to write complex PHP Web applications. Congratulations! Before concluding the book, however, it's worth taking a look at how to write high-quality applications. The term "high-quality" is somewhat subjective, but for the purposes of this book it means code that:
Is easy to read, maintain, and extend
Is secure â that is, protected from attacks
Handles error conditions and problems in a robust and graceful way
Is well tested
As your Web applications grow larger and more complex, the quality of your code becomes more and more important. A large code base can quickly become error-prone and difficult to work with if strict quality standards aren't maintained. In this chapter you learn the following quality-control techniques:
Splitting your code into manageable, reusable chunks
Using a set of coding standards to keep your code easy to read
Writing documentation to improve readability for other programmers who work on your code
Validating input, as well as encoding output, to mitigate the risk of security holes in your code
Dealing with error conditions â that is, handling abnormal situations while your code is running
Cleanly separating your application's business logic from its user interface
Using automated testing frameworks to improve the quality of your code
By the end of this chapter you'll have the know-how to create PHP applications that are robust, ...
Get Beginning PHP 5.3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.