PHP Programmer 40-point bad habits

Source: Internet
Author: User
Tags zend

1, do not write comments

2. Do not use IDE tools that can improve productivity

3. Do not use version control

4. Do not write code according to programming specifications

5, do not use a unified approach

6. Do not think and plan before coding

7. Do not perform encoding and security detection before executing SQL

8, do not use test-driven development

9. Do not turn on automatic error when encoding (error_reporting)

10, do not use a good debugging tool

11. Do not refactor your code (refactor)

12, do not use a hierarchical structure such as MVC

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

14, in a function or class directly with print or echo output things instead of return (return)

15, do not use or to understand unit testing

16. Return HTML instead of data,strings,objects type

17. Bad code and configuration parameters (hard code messages and config parameters)

18. Do not optimize SQL query

19, do not use __autoload

20, does not support automatic error operation (should be intelligent error correction)

21. Use $_get instead of $_post to carry out dangerous parameter transfer (remember that these 40 items are all wrong)

22, do not know how to use regular expressions

23, never heard of SQL injection and cross-site scripting (security aspects, should understand the following two things in English: SQL Injection,cross-site scripting)

24, do not support simple configuration, pass parameters to the class constructor, Set/get method, define constants

25. Unable to understand the pros and cons of OOP

26. No matter how small it is to be done, use OOP

27. The software that is considered to be reusable is OOP

28. Do not use default values (Don ' t choose Intelligent defaults)

29, do not use a single configuration file

30. Don't want others to see the code, but use. Inc to replace it. php

31. Do not use the database abstraction layer (persistence layer)

32, development is not dry (Dont repeat yourself). (that is, always develop repetitive things)

33. Do not develop classes or methods that can be reused

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

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

36, do not allow users to define the base directory (this is as if PHP is not suitable, after all, not based on operating system development)

37, the wrong use of namespaces, using the commonly used words as a prefix. (This can cause a conflict after someone else uses it.), for example, define a function called Array_push ())

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

39, do not use or use a strange template engine (easy to team development, everyone to use the common template)

40, not to see the framework of PHP (most of the framework contains excellent code and advanced concepts. Worth learning)

The following is the original text:

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

2. Don ' t see the need and/or benefits of a good programming ides like Zend Studio or Eclipse PDT

3. 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 pro Ject

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

t see the benefits of a debugger

One. Don ' t refactor your code

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

Don ' t know what these stand For:kiss, DRY, MVC, OOP, REST

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

Never seen the advantage of unit tests or testing in general

Return HTML, not data, strings, or objects.

Hard code messages and configuration parameters

Don ' t optimize your SQL queries

. Don ' t use __autoload

Don ' t allow intelligent error handling

$_get instead of $_post for any destructive actions

Don ' t know how to use regular expressions

* you ' ve never heard of SQL injection or Cross-site scripting

. Don ' t allow simple configuration, can is parameters passed to a class ' s constructor, Set/get methods called Later, or Constants defined at a runtime.

Don ' t understand the benefits and limitations of Object oriented programming

Misuse oop/everything You write, no matter how small is OOP

Think reusable software equals/requires your code to be OOP

Don ' t choose Intelligent defaults

The. Don ' t has one single configuration file

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

. Don ' t use a database abstraction layer

Don ' t keep it DRY, don ' t repeat yourself. If you had to copy and paste or duplicate something your design is off.

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

Don ' t try to take advantage of the OOP specific features like abstract/interface classes, Inheritage polymorphism & AC Cess modifiers.

Don ' t optimize your application design with established design patterns

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

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

t allow a table prefix when using the database tables

Use a separate template engine

  don ' t take a look at established PHP frameworks for inspiration, and most of them has advanced web dev concepts and good code

 
 
 
 
 
 
Reinhold Weber have put together a list of signs (all On he "programming list of Shame") that's you ' re a lousy PHP programmer. Here's a sampling:
Don t see the need and/or benefits of a good programming ides like Zend Studio or Eclipse pdt have never used some form of version control like subclipse 
Don's use a consistent methodology 
don ' t u Se test-driven development 
Don ' t return content but echo or print it from your functions or classes 
Retu RN HTML, not data, strings, or objects. 
Don't allow intelligent error handling 
Think reusable Softwa Re equals/requires your code to being oop 
now granted, some of them is a bit more high level than others, but if yo U ' re not headed towards a lot of these, your might change paths, hop out of that comfort zone and branch out into the the Commu Nity and the language a little bit more.

PHP programmer 40-point bad habits

Related Article

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.