Talk about the understanding of object-oriented thinking

This problem usually makes many people feel a little overwhelmed. It feels like I have been coding, but when it comes to thinking, it is difficult to elaborate.

Next, let me talk about my thoughts,

First, talk about "process-oriented" vs "object-oriented"

I think the two are the difference in thinking angles. Process-oriented is more from the perspective of the **"executor" , while object-oriented is more from the perspective of the "organizer"**, for example For example, if I want to generate a random number between 0 and 10, if I use a "process-oriented" thinking, then I pay more attention to how to design an algorithm, and then ensure that the random number between 0 and 10 is generated in a balanced manner. Object-oriented thinking will pay more attention. I will find someone to help us do this, such as the Random class, just call the methods provided in it.

Therefore, object-oriented thinking is more about how to choose the right tools, and then organize them together to do one thing.

Just like a director who wants to make a movie, then first there must be male pig's feet and female pig's feet, then there are other things, and finally these resources are organized to make a movie.

Returning to our programming world, the thinking of this organizer is everywhere. For example, if we want to develop projects and develop them in a three-tier structure, then at this time, we don’t need to reinvent the wheel, just choose the mainstream ones on the market. The framework is enough, such as SpringMVC, Spring, MyBatis, these are the mainstream frameworks of each layer.

Guess you like

Origin blog.csdn.net/zs18753479279/article/details/114110206
Recommended