Object-Oriented Thinking Method

  java, question

I learned C language, and he is process-oriented.
When I was studying object-oriented, I found that there were many differences between thinking about problems in process and thinking about problems in reality.
Please tell us how you think about object-oriented problems.

Thank you all

C is for procedural language, and the methods defined in the code are generally called all the time. However, in object-oriented languages (such as Java) or object-based languages (such as JavaScript), methods are defined on objects or classes (ps:js does not explicitly refer to classes). For example, there is a way to compare sizes:

In c language:

int compare(int num1,int num2){
 return num1>num2?  num1:num2;
 bracket
 
 //call
 compare(1,2);

In Java

public class Compare{
 private int num1;
 private int num2;
 
 public Compare(int num3,int num3){
 this.num1=num3;
 this.num2=num4;
 bracket
 
 public int com(){
 return this.num1>this.num2?  this.num1:this.num2;
 bracket
 bracket
 
 //call
 Compare cpm = new Compare(5,6);
 System.out.println(cpm.com());

The above simple example is to distinguish different thinking modes of process-oriented and object-oriented for the same problem. Although no object-oriented breakthrough point can be seen here, in actual projects, there are many methods and a large amount of coding. In this case, the class can organize the code very well, for example, a user has different behaviors such as eating, walking, sleeping, entertainment, etc.
In C language, the implementation might look like this:

void eating(){}
 
 void walk(){}
 
 void sleep(){}
 
 void entertainment(){}
 
 ......//Define Other Methods

In an object-oriented language, the implementation might look like this:

public User{
 void eating(){}
 
 void walk(){}
 
 void sleep(){}
 
 void entertainment(){}
 
 //other methods
 bracket

Obviously, the object-oriented code structure has been well assembled, making it easier for people to understand. KUKE has an article on understanding object-oriented:
This understanding of object-oriented programmingI hope it is helpful for the subject to understand object-oriented.