A summary of Reading Java programming ideas (I.)

Source: Internet
Author: User

learning without thinking is not the case, but thinking without learning is dangerous.I. Objects (object)

1, the Machine model (program space), the actual problem solving problem model (problem space).

2. We refer to the elements in the problem space and their representations in the schema space as "objects" (object).

3. OOP (Object-oriented programming) allows us to describe a problem based on a problem rather than a scenario.

4, compared with the real world "objects" or "objects", the Programming "object" also has their own characteristics and behavior.

Second, Java object-oriented programming method

1, all things are objects, you can think of the object as a new variable, it holds the data, you can ask it to operate on itself.

2, the program is a large push object combination, through message delivery (such as method calls), each object knows what to do.

3, each object has its own storage space, can also accommodate other objects (other objects must be private).

4. Each object has a type. The most important feature of a class is what messages can be sent to it.

5. All objects of the same class can receive the same message.

three, interface (interface)

1, in the real world, each species has its own characteristics and behavior, such as human, black, white and other characteristics, people can speak, can walk upright these behaviors.

2, in the program world, each object is subordinate to a specific "class", this class also has its own behavior and common characteristics.

3, therefore, in object-oriented programming, we have to establish a variety of classes (class), according to the actual situation to generate many objects. These objects are then handled in the element as an issue to be resolved.

4. How to establish an ideal one by one correspondence or mapping between elements of a problem space and elements of a schema space? This has the presence of an interface (interface). Each object can receive a specific request, and we want the object's request to be defined by its interface (interface), which defines its interface form. The equivalence or correspondence between classes and interfaces is the basis for programming design.

Take the light bulb as an example, there is an open light, turn off the light, dimming, dimming and other interfaces. To invoke it, you need to create (new) An object that is called through the object's handle.

Iv. hiding the implementation of the scheme

1, plainly is access control

The same class Same package
Sub-classes of different packages Non-subclasses of different packages
Public can access can access can access can access
Protect can access can access can access
Default can access can access
Private can access

2, the reuse of the scheme, many people think that the reuse of design scheme is the most great lever of object-oriented programming. We take those public methods out and encapsulate them as an interface, and then provide the other objects that need to inherit reuse.

3, Inherit (extends), re-use the interface. For example, the parent class has a way to run, and when the subclass inherits the parent class, the subclass has one more method of the parent class in addition to its own method. We can improve the behavior of the parent method function, or we can directly inherit its behavior.

4, the creation of objects and the existence of time.

A summary of Reading Java programming ideas (I.)

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.