When I saw a Java programmer ask such a question, I asked it casually. I now work in an internet company, just write code time is not long, the leader sometimes say my code quality is not good, how can I improve my skills? The daily work is the system's function optimization, write the function class code.
Reply content:
Laxatives...
Well, that's it. Take me personally. (I'm a bit of a fool)
The first is
Masturbate Code, PHP is a handy language, but it doesn't mean it's easy.
A lot of code found that many of the code can be repeatedly referenced. So I learned.
"Encapsulation"
----------------------------
found that their own encapsulated code or development efficiency issues, so I search the Internet solutions, found that PHP has a lot of
FrameCan be used, can save a lot of time.
----------------------------
After many projects I found that a lot of slightly larger projects difficult to control the quality of the code, such as the East piece of the west piece of code, the need for what function in the direct code in which block, I found this is not right, I tried to surf the Internet to view the solution so I learned
"design mode"。
------------------------------
I started to find out that I was. My server crashed, I found that I wrote the SQL has a performance bottleneck, on a server to run, so I learned,
Optimizing SQL。
-------------------------------
I also found it useful to optimize SQL alone or wood. So I learned it again,
MySQL read-write separation。。
------------------------------
Now the problem is again, database optimization alone is not enough, so I learned
Load Balancing
------------------------------------
then is the cache, middleware, nosql,php expansion development.
In short: Do not accumulate kuibu not even thousands of miles.Discovering, practice makes perfect, he stone can attack Jade on the issue of code quality, personally think that good code should meet the following criteria, sorted by importance:
1, the availability of. Nothing to say, the code must be to achieve the requirements of the premise, and is able to operate correctly, otherwise neat and graceful as poetry is nothing but excrement.
2, reliability. Code this thing ah, can not add a lot of stunts, see very soon very cow, the results of users with a certain dozens, there is no such code, prove that you write code is false. Good code should logically be able to take into account the various scenarios in the business, as well as stable availability under the pressure of actual online operations. It's easy to say, complex enough modules, used to first build and test the document, and then test, test, test ~
3, readability. Realize the function, pass the test to run on-line, just foundation ...
First, look at the name, whether the word is concise, the meaning is clear, do not use pinyin, do not use pinyin, do not use Pinyin, style is unified (there is no hump and underline the same situation) or whether the team/framework written specifications.
Second, the best to find someone else's code, or oneself has been put down for a period of time, read a large section of the code, read a large section of the code, read a large section of the code ... Read the n-layer nested code, read the N-layer nested code, read the N-layer nested code ... When I read it, I probably knew how to change it.
Three, good writing format, pay attention to the empty line, the use of indentation, in short, to look comfortable.
Iv. comments, comments, comments.
If you do not want to take over the future programmers often greet you mother, now start to change.
4, structural (reusability, maintainability, etc...) )。 "Structured programming" this in the reading, the C language when the things that appear to have no eggs, in fact, is equivalent to the total of the nine swords. Now PHP can achieve a higher degree of abstraction of the object-oriented approach, but also a more comprehensive approach to object-oriented implementation of the previous help to summarize a set of GOF design patterns. Already very happy, master these concepts and various skills, and then forget, return to the idea of structured design, all techniques can be easily picked up, no recruit wins.
5, efficient. As long as the above conditions are helpful, efficiency can be sacrificed to a certain extent, but the other can do the above four code efficiency is not low.
about how to improve, the following is my personal experience:
1, attitude. It is easy to appear in a new job, to take over the maintenance of existing code of the program. Not the code of their own write not actively concerned, not only did not do well, also lost the opportunity to promote. Even more direct copy and paste, with no slightest change. So have a sense of enlightenment: all the code handed to you through your hand, no matter who the original is or your code, you need to be responsible for them.
2, read more. Find some projects to read, good bad can, analysis of their written well, fortunately, where is not good. Reading the code is very boring, to withstand.
3, write more. There's nothing to say.
4, various basic posture. More than PHP, not only the business, where not to point where, self-experience. No, uninvited.
For more than three years PHP programmer to answer
The master remembers that any language programmer is piled up by the amount of code and the number of bugs.
My way of growing up is to brush the source of other people's program, study why to write so.
Encountered more problems, and later encountered the same nature can be directly resolved. You may even know why this problem occurs.
summed up is
See more, think more, realize more. The most basic is to read the manual a few times, while watching while knocking. This is a step that cannot be skipped.
Proficient in HTML, CSS and JS technology, regardless of whether it will be used later, must be proficient.
Thoroughly understand server and database-related deployments and settings are not complete once done.
Then try to understand the design patterns, MVC and other basic knowledge, not only to understand so simple, must be actually used.
Then find some o ' Reilly php about the book to Gnaw, try to find some more comprehensive, more extensive. Recommended "Building a scalable Web site"
Finally, more practice and more communication.
To make a suggestion, many beginners have yet to start talking about performance and load. Don't worry, learn the basics first, learn the basics and then go to see those impracticality things. New PHP Code Farm Group, address is located in Zhongguancun Software Park, welcome to come, common research PHP and jointly solve bug,106243666