Home  >  Article  >  How to write code for beginners

How to write code for beginners

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-08-17 11:14:2533207browse

How to write code for beginners

How to learn to write code as a programming beginner? This is an unavoidable topic. I believe many people are the same, that is, first read the code written by others, and then read the source code of your commonly used libraries and programming frameworks, and read the source code of expert level. It can be said that the first thing that beginners of programming must master is to read Code ability. Only if you can read can you write. In fact, the process of programming is to read the code, modify the code, and run the code. When you really have a deeper understanding of the program code, writing code will not take much effort. As the saying goes, sharpening the knife will not waste time cutting wood. That's the truth.

As we all know, the obvious way to improve your programming skills is to write more code. However, another way to improve your programming skills involves more than just writing code. Of course, reading code cannot replace the function of writing code. Teacher Chen from Shangxuetang pointed out that reading other people’s code is the process of absorbing nutrients. In this article, I will recommend which codes to read. After reading a certain amount, you will find some methods that work.

Related recommendations: "FAQ"

Which codes are suitable for reading? When choosing code reading materials, you must first combine the fields of your study and work. This is a choice of reading direction. However, I will provide you with some references for reading the code, which are good options. When reading code, be good at finding the public APIs in it. This will reduce the barriers to understanding the internal working mechanism. In addition, as a user of code, you can practice adding documents, implementing new functions, etc. to learn and use it.

Choose code that impresses you

The author once came into contact with a website developed by the open source Cappuccino project framework, and conducted a detailed technical analysis of its content. When I come across an impressive app that also uses the Cappuccino framework, I can look back at my old notes and find that I can learn a lot from it. What impresses me is the open source code. Through the application of open source code, your project development capabilities will be greatly improved.

Read the code written by great people

After using some open source software and looking at some open source frameworks, you can always find those great people. I can think of a few enviable code developers. If you don't have a developer you admire, you can easily find one. She/he most likely wrote the code mentioned in the previous two paragraphs (the code you rely on, the code that impresses you). You can excerpt this, or try to modify and apply it.

Read the code you can understand

There are many open source projects on the Internet, but the author does not recommend extensive reading or swallowing them all. Unless you are an experienced code reader. Larger projects include more modules, and you may struggle with complex concepts without learning valuable content. Confusion can be frustrating, and the larger the project, the more likely it is that confusion will interfere with your reading. As a beginner, reading small projects can help you better understand the structure and logic of the entire project, and you can also learn many valuable details from it.

The above is the detailed content of How to write code for beginners. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn