当前位置:网站首页>How to build programming ideas and improve programming ideas

How to build programming ideas and improve programming ideas

2022-08-11 10:03:00 Xiao He Online

One. First of all, what is programming thought?

Programming thinking is a guiding ideology, and this guiding ideology will induce the behavior of how you write code.

If you understand what this means?For example, the Chinese civilization has formed a thought of "unifying the world" in the minds of the people for thousands of years. This kind of thought will induce princes or warlords in various chaotic periods to aim at unifying China, rather than dividing China like Europe.Each is independent, and each is called the emperor as the goal.

So what kinds of programming ideas are there?

1)Procedural Oriented Programming.This is the thinking of most programmers in our country.This kind of thinking induces the phenomenon when they write code: a method is written with a lot of business logic, or the path from the ui layer (point) business logic layer (point) database access layer is written.

2)Functional programming.Typical functions are functions in javascript written by many people.Various businesses are written with various functions.

3)Object-Oriented Programming.This is a relatively advanced and abstract idea. It has three characteristics and five principles.That is, encapsulation, inheritance, polymorphism, singleness, opening and closing, Liskov substitution, dependency inversion, and interface isolation.

Digression: Some people will tell you data structures and algorithms. What I want to tell you is that it is not a programming idea, but a programming ability. It tests your logical operation ability. The better you are, the more complex technology you will deal with.The field can go deeper, and eventually you can reach the category of a scientist.

Second, the pros and cons and choices of programming ideas.

Procedural and functional programming are the original ideas of every recent graduate.That is, as long as he learns programming, the code he wrote at the beginning is this kind of thinking, and he does not need to teach it.

The object-oriented programming is advanced abstraction.In essence, the evolution of a programmer is actually the process of cultivating, forming, developing and maturing the idea of ​​object-oriented programming.

So, you should now know what the best thinking is, yes: Object Orientation.

Third, how to establish programming ideas

First of all, you must always keep in mind the three major characteristics and five principles of object-oriented. You are very familiar with those words, but you absolutely do not know the terrifying power contained in them.That is: it is one thing for you to recognize the word, it is another to understand and use it.

Then, you have to think about whether you are using its features and principles in your practice.

Finally, keep trying to fix and change your code, and slowly, your object-oriented programming ideas will start to build.

Fourth, how to practice, train and improve programming ideas

1. By learning design patterns.

At the beginning, you are unlikely to have object thinking yourself, because you have not yet formed object thinking. At this time, you need to use previous models to summarize, practice continuously, and write patterns for patterns.raise it.

2. By constantly refactoring the written business logic code, it requires a lot of practice, so that it can make you feel that it conforms to the three major characteristics and five principles.

3. To judge whether a code is well written or not, whether it conforms to the idea of ​​object programming, there is a very simple and crude standard:

Your method body, remove the comments. If you can make the logic of each method in your method body, the number of lines of code in his method body is no more than 30 lines, then you are estimated to have written effectively.If you can find many of your method bodies, when the number of lines of code is only within 10 lines of single-digit code, your object-oriented programming thinking has matured.

4. Keep the code thinking constant.

It takes a long process to change your original procedural programming thinking through continuous practice and practice. From my practical experience, it takes at least 3 years of practical training, so in this sense, 599% of Chinese programmers under the age of 20 are not object-oriented.When you no longer write patterns for patterns, and the code you handwrite is so concise and beautiful, you are already better than 95% of Chinese programmers.

原网站

版权声明
本文为[Xiao He Online]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/223/202208110957325434.html