Dark Horse Programmer —————— > Object Oriented

Source: Internet
Author: User

First of all.. The three structure sequence structure of the program, the choice structure, the circulation structure, these three kinds of basic control structure all have the unique exit and the entrance, has the good correspondence between the static form of the program and the dynamic execution flow, the Java body is composed of these three kinds of program structure, in other words, although Java is Object-oriented, But Java's approach is a structured flow of programs.

Object-oriented is a better programming algorithm, its basic idea is to use classes, objects, inheritance, encapsulation, messages and other basic concepts of programming.

A software system developed in object-oriented way, the smallest program unit is a class, these classes can generate multiple objects in the system, and these objects are directly imaged into the objective world of various things.

The object-oriented approach has three basic features: encapsulation, inheritance, polymorphism. Encapsulation refers to the implementation of the object to hide the details, and then through some common methods to expose the function of the object, inheritance is the object-oriented implementation of software reuse into the means, when the subclass inherits the parent class, the subclass as a special kind of parent class, will get the property and method of the parent class directly Polymorphism refers to a subclass object that can be assigned directly to a parent class variable, but the runtime still shows the behavior characteristics of the subclass, which means that objects of the same type may exhibit multiple behavioral characteristics when executing the same method.

In addition, abstraction is an important part of object-oriented, and abstraction ignores aspects of a subject that are not relevant to the current goal, paying full attention to the aspect related to the current goal. Abstraction does not intend to understand the whole question, but only part of it.

Although abstraction is an important part of object-oriented, it is not one of the object-oriented features, because all programming languages require abstraction. When developers are abstracting, they should consider what features are required by the software system, and these characteristics should be documented and displayed by the program. Therefore, it is necessary to abstract which features are not specified, but depend on the functional requirements of the software system.

Object-oriented also supports several features,

1: Object is the most basic concept of object-oriented method, its basic features are: Identity uniqueness, sub-type, polymorphism, encapsulation, module independence is good.

2: A class is a kind of thing with common properties and common methods. A class is an abstraction of an object, and an object is an instance of a class. While the class is the smallest unit of the whole software system, the encapsulation of the class hides various details and exposes the functions provided by this kind of external lock through public methods, thus improving the cohesion of the class and reducing the coupling between the objects.

3: Such mutual cooperation between objects requires a mechanism to assist, such mechanisms are called messages. A message is a mechanism by which an instance communicates with another instance.

4: In an object-oriented approach, the mechanism for sharing properties and operations between classes is called inheritance. Inheritance has transitivity. Inheritance can be divided into single inheritance and multiple inheritance. Because multiple inheritance can cause confusion in the inheritance structure, and can greatly reduce the understanding of the program, Java does not support multiple inheritance +

In the Java language, everything is an object, except for the 8 primitive type values, and the object is the center of object-oriented programming. Objects are anything that people want to study, from the simplest integers to the complex planes that can be seen as objects, not only to represent specific things, but also to represent abstract rules, plans, or events.

An object has a state, and an object uses data values to describe its state. Java describes the state of an object by defining a member variable for the object, and the object has operations that alter the state of the object, which is also known as the behavior of the object, and Java describes the behavior of the object by defining the method for the object.

The object implements the combination of data and operation, and the object encapsulates the data and the operation of the data into an organic whole.

Objects are the core of Java programs, so objects in Java are unique, each object has an identity to reference it, and if an object loses its identity, the object becomes garbage and can only be recycled by the system garbage collection mechanism. The Java language does not allow direct access to objects, but rather to manipulate objects by referencing them.

Classes and objects

The abstraction of a group of objects of the same or similar nature is a class, which is a description of a class of things, an abstract, conceptual definition, and an object is an individual of the actual existence of that kind of thing, because it is also called an instance.

An object's abstraction is a class, the materialization of a class is an object, or an instance of a class is an object. Class is used to describe a series of objects, the class outlines the data each object should include, and the class outlines the behavior characteristics of each object. Therefore, the class can be understood as a concept, defined, which regulates the data and behavior characteristics common to certain types of objects.

The Java language uses the CALSS keyword to define classes, which can be used when defining a class to describe the data of a class object, using methods to describe the behavior characteristics of the class object.

Dark Horse Programmer —————— > 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.