Explains java object-oriented and Information Hiding Models
Source: Internet
Author: User
This article explains java's object-oriented and Information Hiding model-Linux general technology-Linux programming and kernel information. The following is a detailed description. Object-oriented technical model: If I want to send flowers to my girlfriend who is far away from the field, I cannot send them to mm because distance is too far away, although I would like. However, sending her flowers is quite easy. I only need to describe the detailed addresses of my mm, the variety, quantity, and delivery time of the flowers in the local flower shop. You can entrust a chain flower shop in the city where my mm is located to deliver the flowers to my mm.
What is the relationship between this and object-oriented? Let me explain.
The process of sending flowers can be divided into several agents. (Because it cannot be represented by graphs, it can only be represented by chained links)
Path 1: flower from my flower shop to mm.
2: The flower shop in the city where mm is located-send flowers to mm
3: flowers from mm city-flowers from mm City
4: the garden-gardener-wholesalers-flower merchants-flowers for flowers-flowers for mm
We can all use the above 4 methods. To achieve our goal. However, we will not care about how the florist works. The florist can call or fax the chain store of the flower shop in the city where mm is located, and then the chain store, according to the requirements of my orders, select the freshest flowers and send them to my mm. The specific implementation process is information hiding. We only need to send the flowers to mm. This is the hidden implementation.
The process for the program is the same as that for the mm program. An Object-Oriented Program is composed of an interactive proxy group, that is, the above flower vendors, flower recipients, and planters. These are objects. Each object has its own role, and each object provides a service and an action.
Epiphany of class hierarchies:
The specific objects in the above model, such as flower merchants, can be divided into local flower merchants and flower merchants in the city where mm is located, but they are both flower merchants and the boss of local flower merchants, and the boss of the flower merchants in the city where mm is located. They are all shopaholics, and they are all classes. Here, the boss's father class is human, the human father class is a mammal, while the mammal belongs to an animal, and the animal eventually belongs to our Object class. We are all objects, and cats and dogs are also objects. You and I are all object-oriented.
The inheritance relationship of the class is: Flower Shop Girl-flower shop owner-shopkeeper-human-mammal-animal-object
We can find that we inherit all the features from the ancestor to the current individual, such as the object attributes of animals. He may have four legs, while a mammal inherits the attributes of an animal and has his own attributes, because he is breastfeeding. People inherit the attributes of mammals and have their own characteristics, such as speaking and walking. The shopkeeper also inherits the characteristics of people and has his own attributes. He has the rights of the shopkeeper because the store is his, and the boss inherits some attributes of the shopkeeper, such as rights, but he is still the shopkeeper's wage earners. However, Huadong only has its own attributes. But it also inherits the most basic attributes of objects. The Inheritance attributes at this layer clearly explain the inheritance relationships of java classes.
The above is what I learned today. I hope it will be helpful to you.
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