Talk about my thoughts on reading source code from a problem discussion

image

image

image

image

image

image

image

image

image

image

image

image

For example, in this article, students who do not have deep thinking are easily confused by the superficial phenomenon, thinking that the problem is solved, and immediately close the article. However, students who think deeply will choose to pay attention to the Fei Chao official account, and then put the star on the top, and think, why can Fei Chao quickly find this key category? This is the core issue! Must understand what is meant by "solving a problem" and "solving a type of problem"! If you have not mastered the methods and skills of analyzing the problem, next time you encounter other annotations, you still can't solve it, what's the point?

image

analyse problem

Since Fei Chao has written the source code analysis of the Dubbo series before, and the official accounts are mostly old fans, then I will take Dubbo as an example to talk about the idea of ​​analyzing the problem. Of course, students who like to raise the bar at this time may have to refute. Isn't this question Springboot's, what does it have to do with Dubbo? All I can say is that excellent code and routine ideas are basically the same, but the code that is cheating has different ways of cheating. Taking Dubbo for analysis does not affect the nature of the problem you found!

For example, Dubbo often emphasizes "micro core" and "plug-in". Liang Fei once mentioned

Now that it is necessary to expand, the loading method of extension points must first be unified. The micro core + plug-in type is a way of thinking that can achieve the OCP principle. A plug-in life cycle management container constitutes the micro core. The core does not include any functions. To ensure that all functions can be replaced, and that the framework author can do the functions, the extender must also be able to do so to ensure equal treatment of third parties. Therefore, the framework's own functions should also be implemented in the form of plug-ins. Any hard coding.

Many students looked confused after reading this paragraph. Actually the second half of this passage is the key

Extenders must also be able to achieve the functions that the framework author can do to ensure equal treatment of third parties. Therefore, the functions of the framework itself must also be implemented in the form of plug-ins, without any hard coding.

So from this passage, Fei Chao can conclude that actuatorif he wants to use the timer function, he must start the timer function from the perspective of ordinary users, that is, fans of the official account .

In other words, spring-boot-starter-actuatorin the middle, there must be some @EnableSchedulingannotations on the class , rather than the scattered calls to annotate the underlying encapsulation. This is the theoretical basis. This theoretical basis can determine the direction of your next thinking and action.

With a theoretical foundation, the key is, which category is marked! At this time, we can use idea’s search skills to

image

Idea's search function is very easy to use, search scope can be set up in various scopes, and the necessary skills to see the source code!

Considering that everyone’s shortcut keys are different, so look at the picture below

image

Knock on the blackboard

Seeing this, many people can easily understand that this article is an article introducing the skills of idea. Again, you must think deeply when looking at the problem. The source code is endless, but the means to solve the problem 套路are limited. Many students look at the source code just by watching the process. It feels like watching a movie without personal independent thinking, so the conversion rate of knowledge is too low. For example, you look at my analysis of this article 理论基础to 实践these experiences, all you need from a lot of reading the source code to continue summarized.

So, please don’t ask Fei Chao again, "Look at the source code, is it useful", "How to read the source code" and other questions, because I answer these two questions in every source code analysis and source code combat. If you still ask This kind of problem, it can be seen that you have not paid attention to Fei Chao at all, or have paid attention to no star at the top!

In addition, various source code analysis series (pay attention to Fei Chao's terminology, I am talking about series) are still being updated continuously, welcome to continue to pay attention and "chasing drama" together!

Write at the end

image


Guess you like

Origin blog.51cto.com/15082403/2591242