Java programming thought Nineth Chapter interface

Source: Internet
Author: User

9.1 Abstract classes and abstract methods

Why do we have abstract classes?

is the desire to manipulate a series of classes through a common interface.

So what is the form of abstract classes?

Declaring the use of a class uses the abstract keyword and should have an abstract method in that class.

Note: Abstract methods are modified by the keyword abstract method.

The compiler prevents us from instantiating an abstract class.

9.2 interface

An interface is a further abstraction of an abstract class.

An interface declaration uses the interface keyword, and the fields in the interface are implicitly added keywords: static and final.

Interfaces want to be exported class implementations need to be done by keyword implement.

The methods in the interface are defined by default as public abstract.

9.3 Complete Decoupling

Complete decoupling using the policy mode, adapter mode, and proxy mode.

9.4 Multiple Inheritance

Interfaces and interfaces are functions that can be enhanced by multiple inheritance.

9.5 Extending the interface through inheritance

When using an inheritance extension interface, avoid defining the same names in different interfaces. This causes the compilation exception to occur.

9.6 Adapter Interface

The class is adapted to the interface through the adapter mode.

Domains in the 9.7 interface

The domain in the interface is static final by default.

9.8 Nested interfaces

When implementing an interface, you do not need to implement any interfaces nested inside it

9.9 Interfaces and factories

Creates an implementation object for an interface through Factory mode.

Provides a number of mechanisms for reuse.

Summarize:

In fact, is there a case of abuse in the interface (referring to the interface between the service and the DAO layer)?

At present, it is still not visible, perhaps their understanding of the framework is not deep enough?

But providing a template through an interface is a good way to implement it. is also a good programming idea.

In addition, the use of the intermediate interface in the project is relatively small.

Still need to accumulate more experience, want to think more!

Java programming thought Nineth Chapter interface

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.