改掉这些坏习惯,你不在是菜鸟,改掉坏习惯不在
改掉这些坏习惯,你不在是菜鸟,改掉坏习惯不在
1. 不会利用如phpDoc这样的工具来恰当地注释你的代码
2. 对优秀的集成开发环境如Zend Studio或Eclipse PDT视而不见
3. 从未用过任何形式的版本控制系统,如Subclipse
4. 不采用某种编码与命名标准,以及通用约定,不能在项目开发周期里贯彻落实
5. 不使用统一开发方式
6. 不转换(或)也不验证某些输入或SQL查询串(译注:参考PHP相关函数)
7. 不在编码之前彻底规划你的程序
8. 不使用测试驱动开发
9. 不在错误开启状态下进行编码和测试(译注:参考PHP函数error_reporting)
10. 对调试器的好处视而不见
11. 不重构你的代码
12. 不使用类似MVC模式把程序的不同层次划分开
13. 不知道这些概念:KISS, DRY, MVC, OOP, REST
14. 不用return而是直接在你的函数或类中输出(echo/print)内容
15. 对单元测试或通用测试的优点视而不见
16. 总是返回硬编码的HTML,却不返回纯粹的数据,字符串,或对象
17. 总是对“消息”和“配置参数”进行硬编码
18. 不对SQL查询语句做优化
19. 不使用__autoload(译注:参考PHP手册相关描述)
20. 不允许智能错误处理(译注:参考PEAR的ErrorStack)
21. 使用$_GET替代$_POST来做具有破坏性的传递操作
22. 不知道怎么利用正则表达式
23. 从未听说过SQL注入或跨站脚本
24. 不允许简易配置,也不允许类的构造函数接受参数传递而后执行set/get方法,或运行时的常量定义
25. 不理解面向对象编程(OOP)的优势和劣势
26. 不视情形大小而滥用OOP
27. 自认为实现可复用的软件一定等于/需要让你的代码遵循OOP
28. 不利用智能缺省值
29. 没有单一的配置文件
30. 不想暴露文件源码,却用.inc后缀名取代了.php
31. 不使用数据库抽象层
32. 不能保持DRY作风,即不重复自己,如果你总是在复制粘贴一些东西,说明你设计得很差劲
33. 没有实现让一个函数/类/方法只做一件事,也不能组合利用它们
34. 没能尝试OOP的特长,如抽象类、接口、多态、继承,访问控制修饰符(译注:如public, private, protected)
35. 不用现有的设计模式优化你的程序体系设计
36. 不允许你的用户在你拥有很多文件或目录的情况下定义基础目录
37. 污染了名称空间,比如用常见字符串命名你的库函数
38. 使用数据库表时不使用表前缀
39. 不使用统一的模板引擎
40. 不关注已有的PHP开发框架,懒于探索;其实先进的开发理念和美妙代码就蕴含其中。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use GitLab for project document management 1. Background introduction In the software development process, project documents are very important information. They can not only help the development team understand the needs and design of the project, but also provide reference to the testing team and customers. In order to facilitate version control and team collaboration of project documents, we can use GitLab for project document management. GitLab is a version control system based on Git. In addition to supporting code management, it can also manage project documents. 2. GitLab environment setup First, I

Introduction: PHPDoc is a comment standard for PHP code that produces easy-to-understand and informative documentation. By using specific comment tags, PHPDoc allows developers to provide important details about functions, classes, methods, and other code elements. This advanced guide takes an in-depth look at PHPDoc, demonstrating its capabilities and providing effective documentation strategies. Syntax and tags: PHPDoc comments start with double slashes (//) or multi-line comments (/**/). Here are some common annotation tags: @param: Defines the parameters of a function or method. @return: Specifies the return value of the function or method. @throws: Describes exceptions that may be thrown by a function or method. @var: defines the attributes or instances of the class

Many friends will check the status of their express delivery in the Cainiao parcel software, and some friends expressed that they want to know how to set up and enable delivery notifications. Let me introduce the operation method for you. Friends who don’t know yet should take a look. 1. After opening the Cainiao Wrap APP on your mobile phone, click "My" in the lower right corner of the page to switch to enter. 2. Click the "Settings" icon in the upper right corner of my page to open it. 3. Next, there is a "Message Notification" in the settings page. After finding it, click on it to enter. 4. Find the "Delivering" item on the package notification settings page, and click the corresponding switch button behind it to set it. When the button is blue, it means that the function is turned on. When the courier status changes to being delivered, we will be notified.

Cainiao announced its official entry into the U.S. container shipping market, providing e-commerce parcel shipping services to overseas Chinese and international students across the United States. According to the relevant person in charge of the Cainiao Overseas Shopping Export Logistics Department, in the U.S. market, Cainiao provides two major consolidation products: air freight and sea freight. Air freight products focus on timeliness. After shipment from the container warehouse, the fastest delivery time is 5 days; sea freight is cheaper, with the lowest shipping fee of 12 yuan for individual group orders, and the fastest delivery time is 15 days. In addition, Cainiao Consolidation supports automatic synchronization of Taobao orders, one-click consolidation of packages across the entire network, and the ability to check package status. According to previous reports on this site, in November last year, Cainiao announced that its cross-border logistics flagship product "Global Five-Day Delivery" has covered 8 countries and regions around the world. Officially, overseas consumers can place orders on AliExpress Choice in 5 countries. Receive packages from China within working days

As a world-renowned short video social platform, Douyin has won the favor of a large number of users with its unique personalized recommendation algorithm. This article will delve into the value and principles of Douyin video recommendation to help readers better understand and make full use of this feature. 1. What is Douyin recommended video? Douyin recommended video uses intelligent recommendation algorithms to filter and push personalized video content to users based on their interests and behavioral habits. The Douyin platform analyzes users' viewing history, like and comment behavior, sharing records and other data to select and recommend videos that best suit users' tastes from a huge video library. This personalized recommendation system not only improves user experience, but also helps users discover more video content that matches their preferences, thereby enhancing user stickiness and retention rate. at this

As a PHP developer, writing clear, maintainable code is crucial. Code comments are the key to achieving this goal, and phpDoc, as the document generation standard for PHP, provides us with a powerful and standardized comment tool. PHPDoc Basics PHPDoc comments are surrounded by /* and / tags and follow a specific syntax: /*** description of function or class ** @param type $ parameter name description * @ return type description */ function annotation Function annotation provides the following Information: Function description parameter type and description return value type and description For example: /*** Calculate the sum of two numbers ** @paramint$a first number * @paramint$b second number * @returnint and *

PHPDoc is a standardized documentation comment system for documenting PHP code. It allows developers to add descriptive information to their code using specially formatted comment blocks, thereby improving code readability and maintainability. This article will provide a comprehensive guide to help you from getting started to mastering PHPDoc. Getting Started To use PHPDoc, you simply add special comment blocks to your code, usually placed before functions, classes, or methods. These comment blocks start with /** and end with */ and contain descriptive information in between. /***Calculate the sum of two numbers**@paramint$aThe first number*@paramint$bThe second number*@returnintThe sum of two numbers*/functionsum

With the continuous development of computer hardware, the CPU cores in the processor no longer increase the clock frequency individually, but increase the number of cores. This raises an obvious question: How to get the most out of these cores? One solution is through parallel programming, which involves executing multiple tasks simultaneously to fully utilize the CPU cores. This is a unique feature of the Go language. It is a language designed specifically for concurrent programming. In this article, we will explore how to leverage Go language for concurrent programming. Coroutines First, we need to understand
