An overview of object-oriented thinking

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.