Introduction to the object of "Java programming Thought-learning Note (iv)"

Source: Internet
Author: User

Write the preface to this blog:
To make a long story short, I hope to keep my code simple and usable by reading Java programming ideas.
The level of purpose is different, the first specific goal is to understand the characteristics of Java and consolidate the foundation of Java.
The more abstract purposes are as follows:
1, look forward to consolidating the basis of the way to make code beautiful, concise, efficient.
2, so that their own modules can be open and moderate, easy to use.
3, the formation of a code is beautiful aesthetic.

So the introduction to the first chapter of the Java programming idea begins with this.

1.1 Abstract Process
The advantage of Java in relation to imperative languages is that it is modeled only on the problem to be solved. The main abstraction that the latter makes is based on the computer architecture in which the programmer must establish a connection between the machine model (for example, the computer) and the actual model to be solved (within the "Problem space", where the problem exists, such as a business).
The object-oriented approach allows us to add new types of objects that are self-applicable to a particular problem.
Five basic features of object-oriented language: ...;

1.2 Each object has an interface
The class describes a collection of objects that have the same attributes (data elements) and behaviors (functions).
And the request that the object produces, so that the object completes some kind of task such as request, we call the interface.
Here we need to differentiate between the methods produced by the interfaces and the methods generated by the intrinsic behavior of the classes. The majority of methods that are generated by the intrinsic behavior of the class are the interfaces ' requests to the object.

1.2 Service for each object
One of the best ways to develop and understand a program is to think of the object as a "service provider." The program itself provides services to the user by invoking the services provided by other objects for this purpose. My goal is to create (preferably in an existing code base) a series of objects that provide the ideal service to solve the problem.
I think this is the goal of my class design in programming:
Being able to provide the ideal service to other program modules, not just to other working programmers, is the goal of usability.

Another benefit is increased cohesion. (cohesion refers to a system in all aspects of "good combination") This requires that our program each object can do a good job, but it does not try to do more things.

1.4 Concrete implementations that are hidden
Divide the programmer by role into the class creator and the client programmer.
I think the client programmer is the method required by the interface, the behavior of other classes of objects and the specific implementation of the function, the client programmer does not need to care.
Depending on the role and the different roles of the class, there is a function of access control.

1.5 Specific implementations of multiplexing
Combination (different from inheritance)
("Aggregation" dynamic combination, "combination": "Has-a")

1.6 Inheritance
The understanding of "inheritance", two classes with similar functions, avoids duplication of processing.
Inherit, inherit the function, inherit the interface more.
There are two ways to explain the difference between two classes, adding methods and overriding methods.

1.7 Interchangeable objects associated with polymorphism

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Introduction to the object of "Java programming Thought-learning Note (iv)"

Related Article

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.