1: Object Oriented thinking
Object-oriented is a process-oriented programming idea.
Process oriented: Emphasis on the steps of each of these functions
Object-oriented: emphasizes the object and then invokes the function by the object
2: Object-oriented thinking features
A: It's a thought that's more in line with our thinking habits.
B: Complex things can be simplified
C: Turning us from the executor to the conductor
Example:
Buy a computer:
Process-oriented: My understanding of the computer--understand my own needs--find the corresponding parameter information--go to Zhongguancun to buy a computer--bargain--Buy back the computer
Object-oriented: I know I want to buy a computer--the squad leader buys it for me--the monitor buys it back.
Wash Clothes:
Process: Take off your clothes--find a basin--put some washing powder--add some water--throw your clothes in--rub--wash your clothes--wring dry--hang up
Object-oriented: Take off your clothes--open the fully automatic washing machine--throw it in--one click--Hang Up
Eat:
Process oriented: Go to the supermarket to buy food---------------------------------
Object-oriented: Dinner at the restaurant, you-waiter (à la carte)-Chef (cooking)-Waiter (end dish)--eat
Home-cooked things, buy a washing machine and go to a restaurant is too bad, so, find an object.
However, you do not study hard with me, you will be 4000, you object 8000.
3: Put the elephant in the refrigerator
Process oriented:
What are the actions?
A: Open the refrigerator door
B: Loaded into the elephant
C: Close the refrigerator door
Code embodiment;
Class Demo {
public static void Main (string[] args) {
/*
System.out.println ("Open the refrigerator Door");
Open the door of the refrigerator thing, I now just to demonstrate, wrote an output statement
In fact, it may take a lot of action.
This time, the code is a little bit more.
Suppose I had to open the refrigerator door many times,
Code a lot, write it again every time, trouble not
We should use methods to improve
SYSTEM.OUT.PRINTLN ("Loaded into the elephant");
System.out.println ("Close the refrigerator door");
*/
After writing the method, the call changes the
Open ();
In ();
Close ();
}
public static void Open () {
System.out.println ("Open the refrigerator Door");
}
public static void in () {
SYSTEM.OUT.PRINTLN ("Loaded into the elephant");
}
public static void Close () {
System.out.println ("Close the refrigerator door");
}
}
Object-oriented:
How can we be more consistent with object-oriented thinking?
A: What are the classes?
B: What are the things in each class?
C: What is the direct relationship between classes and classes?
The analysis of the elephant in the refrigerator? (How do you analyze which classes are available?) Uml. Noun extraction method. )
A: What are the classes?
Elephant
Refrigerator
Demo
B: What are the things in each class?
Elephant:
Get in
Refrigerator:
Open the door
Close the door
Demo:
Main method
C: What is the direct relationship between classes and classes?
The function of the elephant and refrigerator class is used in the demo.
The code reflects:
Class Elephant {
public static void in () {
SYSTEM.OUT.PRINTLN ("Loaded into the elephant");
}
}
Class Refrigerator {
public static void Open () {
System.out.println ("Open the refrigerator Door");
}
public static void Close () {
System.out.println ("Close the refrigerator door");
}
}
Class Demo {
public static void Main (string[] args) {
Refrigerator Call Open
Elephant calls in
Refrigerator call Closed
}
}
4: Development, design, characteristics
Object Oriented development
is to constantly create objects, use objects, and command objects to do things.
Object-oriented design
is to manage and maintain the relationship between objects.
Object-oriented features
Package (encapsulation)
Inheritance (inheritance)
Polymorphic (polymorphism)
An overview of object-oriented thinking