標籤:des io ar os 使用 sp for 檔案 資料
1、不寫注釋
2、不使用可以提高生產效率的IDE工具
3、不使用版本控制
4、不按照編程規範寫代碼
5、不使用統一的方法
6、編碼前不去思考和計劃
7、在執行sql前不執行編碼和安全檢測
8、不使用測試驅動開發
9、編碼時不開啟自動報錯(error_reporting)
10、不使用一種好的調試工具
11、不重構你的代碼(refactor)
12、不採用MVC這樣的分層結構
13、不知道以下等等概念:KISS,DRY,MVC,OOP,REST
14、在函數或者類裡直接用print或者echo輸出東西而不是返回(return)
15、不使用也不去瞭解單元測試
16、返回HTMl而不是data,strings,objects等類型
17、糟糕的代碼和配置參數(hard code messages and configuration parameters)
18、不最佳化sql查詢
19、不使用__autoload
20、不支援自動錯誤操作(應該是智能錯誤修正)
21、使用$_GET替代$_POST去進行危險的參數傳遞(記得這40條都是錯誤的東西)
22、不知道怎樣使用Regex
23、從未聽說過sql注入和跨站指令碼(安全方面,應該瞭解下這兩個東西的英文:sql injection,cross-site scripting)
24、不支援簡單配置,傳遞參數給類的建構函式,set/get方法,定義常量
25、不能理解OOP的優缺點
26、無論要做的東西有多小,都使用OOP
27、認為做可複用的軟體就是OOP
28、不使用預設值(don‘t choose intelligent defaults)
29、不使用單一設定檔
30、不想讓別人看到代碼,卻使用.inc替換掉.php
31、不使用資料庫抽象層(持久層)
32、開發時不DRY(Dont repeat yourself). (就是總開發重複的東西)
33、不開發可以重複使用的類或者方法
34、不使用抽象類別或者介面類,繼承,多態,封裝.
35、不使用已有的設計模式最佳化你的程式.
36、不允許使用者定義基礎目錄(這點好象PHP不太適合,畢竟不是基於作業系統的開發)
37、錯誤的使用命名空間,使用大家都普遍使用的單詞作為首碼.(這樣以後別人使用會造成衝突.,例如自己定義一個function 叫 array_push())
38、使用資料庫時不使用表首碼(這個很重要...)
39、不使用或者使用一個陌生的模板引擎(方便團隊開發,大家要使用常見的模板)
40、不去看PHP的架構(大多數架構中都包含優秀的代碼和先進的概念.值得我們學習)
以下是原文:
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 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 defaults
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 abstraction 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.
PHP程式員40點陋習