PHP Garbage Code features Introduction _php Tutorial

Source: Internet
Author: User
When we develop a program, often on the internet to collect a lot of other people's program code, but how to correctly choose a good program code to help themselves solve the problem? Let's introduce you to the following

If you're not familiar with the software you want to modify, I suggest you take a look at the software before making a decision. So how can you identify this as a spam code without further research? Here are some indications of 10 PHP spam codes for reference.

PHP Junk Code 1, trying to transform an object-oriented model, or modify a PHP language feature

If you find a class named object, it's likely that the author of the software is trying to transform the object-oriented model (most likely because he doesn't know about object-oriented), so we can expect his modifications to be more than that. In this case, or quickly turn off your phone to hide!

PHP Junk code 2, with custom global variables

Find the Global keyword or $globals variable in your code, if you find the following code:

Global $database, $my, $mainframe;

This is the infamous global variable. If you can tell the latter two global variables to represent what, then I guess you are familiar with my code, or you have supernatural powers. It would be amazing if you could tell me which code would use them. Anyway, stay away from it.

PHP junk Code 3, ubiquitous HTML and SQL

Looking for HTML code and SQL statements in the code, you should be able to quickly tell if the code should appear here. If you find a file that has both HTML and SQL, congratulations, you found the worst software!

PHP junk code 4, too bloated class

Find the largest three class files and see if the name of the class has a clear function? And look at its methods, are they related to each other? If not, scream and leave!

PHP Garbage Code 5, a large number of public variables or static variables

If you find that many variables are defined as "public static", increase your offer by three times times. I don't have to explain why.

PHP Garbage Code 6, multi-layer inheritance relationship

We should try to avoid more than two levels of inheritance relationship. I've spent a lot of time dealing with objects that have too many unrelated behaviors. If you know what is the use of multi-layered inheritance, I will ask you to drink beer.

PHP Junk Code 7, trying to use design mode (just try)

To know whether the author of the code uses design patterns, you only need to retrieve the most commonly used ones, such as factory (Factory mode), decorator (decorative mode), strategy (policy mode), and so on. If so, you can quickly identify if the author is really using these design patterns, or just want to make the code look interesting. If it's the latter, leave soon.

PHP Spam code 8, different error levels under the program disorder

A good application should work correctly at each error level. Use/error_level (. *)/Find code to modify the error level. If so, change to e_strict and run a little bit more.

PHP Garbage Code 9, there is a directory called core

It's a good idea to put this heap of code in a directory called core when the entire application relies on some code to run it. But, in addition to the name of the catalogue, this approach often bodes poorly for design.

PHP Spam Code 10, the template language of their own design

The situation must be fraught with fear. Because these guys are trying to build their own wheels! If you're not careful, you'll find that your day's good times are all about simulating a for loop.


http://www.bkjia.com/PHPjc/446114.html www.bkjia.com true http://www.bkjia.com/PHPjc/446114.html techarticle when we develop a program, often on the internet to collect a lot of other people's program code, but how to correctly choose a good program code to help themselves solve the problem? ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.