Developing robust Code series with PHP, which is now the mainstream development language, is about solving real-world problems in medium-to-large applications. This series of articles focuses on the new features available in PHP 4, which is now a mainstream development language, highlighting a number of tips and tricks to make development work easier. In this series of articles, you'll find many examples and techniques to learn, along with a lot of sample code. In this first article, PHP (as the current mainstream development language) Amol Hatwar from a higher angle how to design and write error-free, maintainable code for medium to large WEB applications.
If you are a developer building a WEB application and need speed, functionality, and platform Independence (platform-independence), then PHP (which is now the mainstream development language) will work for you. and PHP (which is now the mainstream development language) is free, easy to learn and deploy. These are the biggest benefits of making PHP so popular in today's mainstream development language. But these advantages can also become shortcomings. Because PHP is easy to use as a mainstream development language, developers often try to plug the code into the editor when they should have planned and designed it. Moreover, in PHP (as the current mainstream development language), there is more than one way to solve the problem, it is more prone to make that painful mistake, it is difficult to revise after the error.
In this series of articles, you will learn how to avoid many errors. Don't be surprised if you don't fall down and stick to the end, and you'll find yourself trying to write code without errors one or two times. I will also point out the new features available in PHP 4, which is now the mainstream development language, which makes development work easier. Most of the examples I want to cover are practical issues such as script configuration and installation, file handling, and database usage. Even if you are unfamiliar with all this, you will find it easy to understand. However, I assume you have a preliminary understanding of PHP, which is now the mainstream development language. If you need to review it, you will find the resources listed at the end of this article helpful. (See Resources.) )
lay a strong foundation
Writing code in PHP (which is now a mainstream development language) is very similar to writing code in C-like languages. Because they are syntactically similar, they can also cause similar code maintenance problems. When you have to develop large applications, you may want to write a lot of code. As time goes by, the code may become unmanageable, and errors will quickly take its turn. No matter where you hear this statement, don't believe it-at least not all. However, the more important fact is that if you find yourself maintaining code too frequently, the design of your application may be very bad first.
Design Code correctly
The choices you make initially affect the degree of freedom you will have when you write your code later. This makes the right design an important prerequisite. While the design becomes an extra ritual when you solve a trivial problem, you must at least know that it is the right thing to do. Many people think of design and planning as extra overhead. But starting with a bad design or not having a design at all, the result is always sloppy code. Keep in mind that clever coding doesn't make up for bad design. While designing your application is beyond the scope of this series of articles, I will also suggest some questions to keep in mind when designing a WEB application.
Division and Conquest
It is always preferable to design and write large applications with smaller, loosely coupled parts. In this way, each part is maintainable. For example, a content Management system,cms may be distributed across a number of smaller modules such as user authentication, display, content resolution, and view statistics. And, if your module is generic enough, you can reuse the code in other applications that you develop. Programmers often do this, but they still complain. The trick with coding is to have each module have the functionality it absolutely needs and end it. Give a module a lot of functionality, just right.
Never consider it in the page
If you're interested in making your HTML page more dynamic with PHP, which is now a mainstream development language, this section will work for you. When you want to display the date and time on each page so that it looks up to date, it's usually the beginning of the habit. Each HTML page becomes a small PHP (the current mainstream development language) script with a limited number of lines, and the date function is hidden somewhere. If this is what you want, you must recognize that this is the simplest way to make the job implementation. However, imagine what changes you have to make to change the date format that is rendered on the page. You will have to change the code within each page.
Obviously, there is a better way to achieve this goal. My favorite way is to use a configuration file and define a constant in the configuration file, which retains the format string of the date () function. You can then use the date () function where you want it. Each page still ends with a script, but you have to thoroughly minimize the places where you have to make changes to a single line of code.
http://www.bkjia.com/PHPjc/508603.html www.bkjia.com true http://www.bkjia.com/PHPjc/508603.html techarticle developing robust Code series with PHP, which is now the mainstream development language, is about solving real-world problems in medium-to-large applications. This series of articles focuses primarily on PHP (as ...