Study Notes of crazy Java handouts-Chapter 1 Understanding object-oriented and crazy java handout notes

Source: Internet
Author: User

Study Notes of crazy Java handouts-Chapter 1 Understanding object-oriented and crazy java handout notes

Object-oriented features: inheritance, encapsulation, and Polymorphism

UML (Unified Modeling Language)

2.1 object-oriented

2.1.1 Introduction to Structured Programming

 

Figure 2.1 logical structure of Structured Software

 

 

From figure 2.1, we can see that the structural design requires a top-down design approach. In the design stage, we need to consider which sub-modules each module should be divided, which smaller modules are each decomposed ...... And so on until the modules are refined into functions.

 

2.1.2 three basic structures of the program

Any simple or complex algorithm can be composed of three basic structures: sequential structure, select structure, and cyclic structure. That is, the basic structure.

 

2.1.3 introduction to Object-Oriented Programming

The smallest program unit of an object-oriented software system is a class. These classes can generate multiple objects in the system, and these objects are directly mapped to various objects in the objective world.

Figure 2.7 logical structure of an Object-Oriented Software System

As shown in Figure 2.7, an object-oriented software system consists of multiple classes, which represent a class of things with certain characteristics in the objective world. Such things often have some internal state data, for example, a person has various status data such as height, weight, age, and hobbies. Class emblem provides methods to operate on these State data, and also provides corresponding implementation for the behavior characteristics of such things. This implementation is also a method. Therefore, the following basic equations can be obtained:

Member variable (State data) + method (behavior) = Class Definition

 

Compared with process-oriented, object-oriented is easier and easier to use than process-oriented. Let's give an example to illustrate the relationship between them:

Assume that a computer needs to be assembled. The object-oriented components are the main board, CPU, memory stick, hard disk, and other large-granularity components, while the process-oriented components are some diodes and transistors, small-granularity components such as integrated circuits.

In terms of the way of thinking, we also give an example to illustrate their differences:

For example, you want to complete the "pig eight rings eat watermelon" process.

In the process-oriented program world, all functions are centered and the functions are the largest. Therefore, this case will be expressed using the following statement: Eat (pig, watermelon );

In the object-oriented program world, all objects are centered and the objects are the largest. Therefore, this case will be expressed in the following statement: Pig, eat (watermelon );

Compared with the two statements, it is not difficult to find that the object-oriented statements are closer to the natural language syntax: the subject, the predicate, and the object are clear at a glance and intuitive.

 

2.1.4 basic object-oriented features

Object-oriented has three basic features: encapsulation, inheritance, and polymorphism.

Encapsulation: hides the implementation details of an object and exposes its functions through some common methods;

Inheritance: When a subclass inherits the parent class, as a special parent class, it directly obtains the attributes and methods of the parent class;

Polymorphism: The subclass object can be directly assigned to the parent class variable, but it still shows the behavior characteristics of the subclass at runtime, which means that when an object of the same type executes the same method, it may show multiple behavioral characteristics.

 

Objects are uniquely identified, and classes are a type of things with common attributes and methods. A class is the abstraction of an object, and an object is an instance of a class.

Mutual cooperation between objects requires the assistance of a mechanism called "message ". A message is a mechanism for communication between an instance and another instance.

 

2.2 Introduction to UML (Unified Modeling Language)-This section is the basic knowledge.

 

2.3 Java object-oriented features

2.3.2 class and Object

Java uses the class keyword to define a class. when defining a class, you can use member variables to describe the data of the class object. You can use methods to describe the behavior characteristics of the class Object. That is, when defining a class, you can determine the attributes and behaviors of the class's common features.

 

 

 

 

 

 

 

 

 

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.