Bad habits of PHP programmers-Translated by Ma yongzhan

Source: Internet
Author: User
Tags autoload

Copyright statement: original works can be reproduced. During reprinting, you must mark the original publication, author information, and this statement in hyperlink form. Otherwise, legal liability will be held. Http://blog.csdn.net/mayongzhan-ma yongzhan, myz, mayongzhan

Reinhold Weber proposed a 40-point bad habit for PHP programmers. (This e-question only writes a part of the content. The translator finds the original translation. below is the full version)

1. Do not write comments

2. Do not use ide tools that can improve production efficiency

3. Do not use Version Control

4. write code not in accordance with programming specifications

5. Do not use uniform methods

6 don't think about and plan before coding

7. Do not perform encoding and Security Detection before executing SQL.

8 do not use test-driven development

9 automatic error (error_reporting) when encoding is not enabled)

10 don't use a good debugging tool

11 don't refactor your code (refactor)

12. Do not use a layered structure like MVC

13 do not know the following concepts: Kiss, dry, MVC, oop, rest

14. Print or ECHO is directly used in a function or class to output something instead of returning (return)

15 do not use or understand Unit Testing

16. html is returned instead of data, strings, objects, and other types.

17. Hard code messages and configuration parameters)

18 not optimize SQL queries

19 do not use _ autoload

20 Automatic Error operations are not supported (Intelligent Error correction should be adopted)

21 use $ _ get instead of $ _ post to pass dangerous parameters (remember that these 40 items are all incorrect)

22. I don't know how to use regular expressions.

23 I have never heard of SQL injection and cross-site scripting (Security: SQL Injection, cross-site scripting)

24. simple configuration is not supported. parameters are passed to the class constructor, set/get method, and constants are defined.

25 unable to understand the advantages and disadvantages of OOP

26 no matter how small the things are to be done, oop is used

27 think that reusable software is OOP

28 do not use the default value (don't choose intelligent defaults)

29. Do not use a single configuration file

30. Use. Inc to replace. php instead of letting others see the code.

31 no database abstraction layer (persistence layer)

32 don't dry (dont repeat yourself) during development)

33. do not develop reusable classes or methods.

34. Do not use abstract classes or interface classes, inheritance, polymorphism, and encapsulation.

35. Do not use the existing design mode to optimize your program.

36. Users are not allowed to define basic directories (it seems that PHP is not suitable for development based on operating systems after all)

37. The namespace is incorrectly used, and all commonly used words are used as the prefix. (in this case, other users may encounter conflicts. For example, define a function as array_push ())

38. Do not use the table prefix when using the database (this is very important ...)

39 don't use or use a strange template engine (convenient for team development, you should use common templates)

40 don't look at the PHP framework (most frameworks contain excellent code and advanced concepts. It is worth learning)

There are still a lot of problems that the translator can't do. You still need to work hard!

 

The original text is as follows:

 

1. Don't comment your code properly with something like phpdoc

 

2. Don't see the need and/or benefits of a good programming ide like Zend studio or eclipse PDT

 

3. Have never used some form of version control like subclipse

 

4. Don't adopt some Coding & naming standards and general conventions and stick to them at least throughout the project

 

5. Don't use a consistent methodology

 

6. Don't escape and/or validate properly input or SQL queries

 

7. Don't plan your application thoroughly before starting to code

 

8. Don't use test-driven development

 

9. Don't program & test with error reporting on

 

10. Don't see the benefits of a debugger

 

11. Don't refactor your code

 

12. Don't keep the different layers seperated using something like MVC

 

13. Don't know what these stand for: Kiss, dry, MVC, oop, rest

 

14. Don't return content but echo or print it from your functions or classes

 

15. have never seen the advantage of unit tests or testing in general

 

16. Return HTML, not data, strings, or objects.

 

17. Hard code messages and configuration parameters

 

18. Don't optimize your SQL queries

 

19. Don't use _ autoload

 

20. Don't allow Intelligent Error Handling

 

21. use $ _ get instead of $ _ post for any destructive actions

 

22. Don't know how to use regular expressions

 

23. You 've never heard of SQL injection or Cross-Site Scripting

 

24. Don't allow simple configuration, can be parameters passed to a class's constructor, set/get methods called later, or constants defined at a runtime.

 

25. Don't understand the benefits and limitations of Object Oriented Programming

 

26. Misuse OOP/everything you write, no matter how small is OOP

 

27. You think Reusable Software equals/requires your code to be OOP

 

28. Don't choose intelligent ults

 

29. Don't have one single configuration file

 

30. Don't want the file contents to be seen, but give it a. inc extension instead of. php

 

31. Don't use a database using action Layer

 

32. Don't keep it dry, don't repeat yourself. If you have to copy and paste or duplicate something your design may be off.

 

33. Don't make a function/class/method do just one thing and don't make them interact.

 

34. Don't try to take advantage of OOP specific features like abstract/interface classes, inheritage polymorphism & access modifiers.

 

35. Don't optimize your application design with established Design Patterns

 

36. Don't allow your user to define a base directory if you have multiple files and/or directories

 

37. pollute the global namespace, one option is to prefix the functions in your library with a common string

 

38. Don't allow a table prefix when using database tables

 

39. Use a separate template engine

 

40. Don't Take A Look At established PHP frameworks for inspiration, most of them have advanced Web Dev concepts and good code

 
 
 
 
 
 
Reinhold Weber has put together a list of signs (40 in all on his "programming list of shame") that you're a lousy PHP programmer. Here's a sampling:
Don't see the need and/or benefits of a good programming ide like Zend studio or eclipse PDT
Have never used some form of version control like subclipse
Don't use a consistent methodology
Don't use test-driven development
Don't return content but echo or print it from your functions or classes
Return HTML, not data, strings, or objects.
Don't allow Intelligent Error Handling
You think Reusable Software equals/requires your code to be OOP
Now granted, some of them are a bit more high level than others, but if you're not headed towards a lot of these, you might change paths, hop out of that comfort zone and branch out into the community and the language a little bit more.
 
 

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.