Java object-oriented features-a nutshell

Source: Internet
Author: User

The basic characteristics of Java Basic Learning Summary, the beginning of learning, is a metaphysical understanding, with more than 3 years, and then look back, it is quite logical to understand

Language learning is probably such a law, learning, not very solution, application, application, gradually rooted in, looking back, suddenly a realization

Recently summed up the six principles of design patterns, feeling quite connected, first listed 6 principles:

  Dimitri rule, Richter replacement principle, dependency inversion, interface isolation, synthesis polymerization, open and close principle

The first one, the abstract

Abstractions are not unique to the Java language. Bottom line: Ignore irrelevant details, abstract the behavior and attributes of things , and reflect the fields and methods in the class

The second one, package

  hides internal details and provides only interfaces for communicating with the outside world .

This characteristic has some connection with the Dimitri law, Dimitri law requires that the action of the entities should be as few as possible, so that each class is independent of each other and amplified, each department

The system can be independent of each other, do their own things, colleagues compatible to provide services, the author felt that the word encapsulation is used to describe small services, micro-services are also quite suitable

Third, inheritance

  A class derives from subclasses, called Inheritance , and derived classes inherit methods and instance variables of the base class, and can overwrite or add new methods

This creates the concept of the subclass parent class. Combining the first feature abstraction, we can see that the principle of dependency inversion is so that abstraction cannot depend on

Specifically, it makes the concrete dependent on abstraction.

If the concept of inheritance is broad, then the implementation of the interface will also produce subclasses and parents, the open and close principle requires internal expansion of the extension, the modification is closed, and inheritance has

A big connection.

Richter replacement principle a simpler understanding is that where subclasses can appear, the parent must also be able to appear and replace, in the programming in fact many places are embodied, most often

See map<xxx,xxx> Map = new hashmap<> (); list<> list = new arraylist<> (); is not to say that must write this, the author starts to use when actually

I don't quite understand why I wrote it until I saw the author's description in the book.

Synthesis and aggregation principles, in fact, better words are combinatorial and aggregation, and now many concepts of the boundaries are actually not so standard or strict, we will inherit and hold,

is generally held limited, holding is holding an instance

In short, a succession of the birth of countless situations, developers get a lot of experience in the practice and principles, this can only be in the design and coding slowly realized

Fourth, polymorphic

The methods of the parent class behave differently in subclasses. There are many states, there is inheritance, there are overrides, there is a parent class reference to the Child class object

Polymorphic examples are too many, do not do web development too much. However, the use of polymorphic derivative design patterns is the essence of the entire 23 design patterns

Everywhere is manifested, the multi-state light, everywhere, our Richter scale substitution principle is the direct embodiment.

The basic features of Java object-oriented actually have nothing to say, it is difficult to derive from a variety of applications, such as inheritance of the class load order, design patterns, and

Our database table design (abstraction and encapsulation capabilities), these later chapters are reserved for summary.

  

Java object-oriented features-a nutshell

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.