The world's first language in hand, supplemented by the best practices of predecessors, what is the world. |
1, the code is written for small white
- Comments, comments, notes, important things say three times. Although we do not take to sell the source of commercial products, do not need to write the comments how beautiful. But do not be too stingy, in the end, they can not understand the logic of their own, if a logic is really not 1+1=2 so simple, write a few words sketchy comments it.
- Enter the parameter detection, enter the parameter to detect, enter the parameter to detect, say three times again, you never know who the person who calls the interface, what is the intention, will not cause damage to you. In order to ensure that your logic only do the right thing, any logical beginning, should be a large part of the legitimacy of the test, do not trust anyone! Put this principle deep in your mind.
2. Don't break the rules to take shortcuts
3. Do not ignore the test
- Never take the chance to think your logic is not a problem, each line of code must be actually run to carefully verify, no matter what means you through, will not use the lightest price to complete the self-test is an important indicator of your research and development capabilities
4. Performance Performance
- Your code is to be used by tens users (self-feeling good cock appearance), any scenario should consider performance, otherwise on-line will be dead very miserable, the dead students can stand out and say two sentences
- Do not invoke external interfaces in loops, such as queues, caches, databases, etc.
- Check each of your own SQL, whether the index is gone, whether it is a big data result set, these are likely to overwhelm the elephant's last straw
- Focus on the response time of the request online, a request of more than 300ms should have the space to optimize
5. Well-named
- Name to be able to see the name of the interpretation, at the same time to maintain coherence, from the member table should be called member, a number of results should be called members, do not take out the changed, such as: $list = $this->member->list_by_ UIDs (...);
6, try to use less continue/break
For example, the following code:
foreach ($ids as $id) { if (!is_martshow ($id)) { continue; } Process the Martshows} |
should read:
foreach ($ids as $id) { if (is_martshow ($id)) { //process the Martshows }} |
Some summary of PHP code specification