Java Object-oriented

Source: Internet
Author: User

As a well-grounded C-language scholar, I was very interested in the object-oriented Java scholar's mouth when I first turned to Java.

At first, based on their own superficial understanding, many programming languages in my opinion is not a small difference, is the analysis of needs, with computer language to solve some problems. At least in the use of C to solve some small problems, to achieve a small function, I have to step-by-step implementation of the function. As we usually do, pay attention to a logic, pay attention to a sequence of priorities. In the process of implementation, what data will be required to set what data to write. However, this will also bring some trouble: if you forget to set some data, you need to go back to set the time, a large segment of the code, to find the appropriate location, to add something will always make people dazzling, error-prone. Simple things are easy to implement, and if you come back and change them in a few days, it really makes a big head.

Recently learned Java language, but not such a programming language. Java is an object-oriented programming language, so-called object-oriented, exactly the same as what I said above in the C language as the representative of the process-oriented architecture programming language. The difference here is not that the Java language does not operate on the steps, but rather that it uses object-oriented thinking, which is to abstract the reality of life into a package with attributes and behaviors. An object is a package of data and allowable operations that directly correspond to an objective entity, and an object class defines a set of objects with similar properties. Each inheritance is a way to share the properties and operations of classes that have hierarchical relationships. The so-called object-oriented is based on object concept, Object-centered, class and inheritance as the construction mechanism, to recognize, understand, depict the objective world and design, build the corresponding software system.

Problem analysis in programming first of all, we need to find the object, the industry has an old saying: "Everything is the object." "Here, we need to add:" The object is generated by concern. "' So looking for people, things or entities that we are concerned about in the problem domain. After the object is found, locate the object's properties and behavior. The property is judged by the relationship between the object and the attribute, with the has a relation, that is, the object has a property, the property needs to be able to be described by the value, when they do not satisfy the relationship between the object and the property, consider whether the use of a relationship, that is, the object is merely invoking other objects or other variables, Set the called object to a local variable. In addition, we need to find the behavior of the object, the behavior is implemented by methods, and the methods involved are to cover the object's actions and functions.

In Java, by extracting objects into classes, it is very convenient for us to describe the object in the problem that we need to solve and their property behavior in programming languages, and to make it easier for our team to classify and edit their behavior. Class, which is an abstraction of an object, an instance of a class. In addition, the functionality inherited in Java is more convenient to abstract objects with the same properties or behaviors to a class that describes them, called the parent class of these objects, and each object must be a type of parent class, satisfying the is a relationship, corresponding to the abstract concept of these objects called subclasses. Then, in the steps to solve the problem, if you want to use it, you just need to call their properties from the established class or write a good way for the behavior. In this way, the function of writing and multiple calls is completed, and the idea of reusing the code is embodied, and the object-oriented programming idea also separates the object from the problem-solving process, and if it needs to be modified, it can only find the object, which embodies a kind of separation of code. The reuse and separation of code is the principle that code follows when it develops in a better direction.

In a word, the object-oriented programming idea and the process-oriented thought of structured programming are the same as the natural thinking. Of course, they each have their own merits and demerits, the actual use of the difference, only to be in practice in the future to delve into.

Java Object-oriented

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.