Interface-oriented programming is oriented to abstract programming. __ Programming

Source: Internet
Author: User

Speaking of interface-oriented programming. I heard a blur.
Problem: Now there are interface A and the B class that inherits a interface, then
A s=new B;
What does that mean???
Then you can adjust the method implemented in class B with the method of a s.print.
And the teacher said that interface-oriented programming is to reduce the coupling degree of the program (what is the meaning of the coupling). More secure than object-oriented. What does that mean?

Question added:

What are the advantages and disadvantages of interface-oriented and object-oriented ratios?
Http://zhidao.baidu.com/question/271744863.html
Interface programming means that the interaction between all classes or modules in an object-oriented system is done by an interface. The
concept is used to generalize, the key is to understand the meaning. Explained as follows:
A s =new B;
Create a B object in the memory heap, create a reference in the memory stack A,a point B. It is certainly correct to use the S.print () method in a to invoke the same method in B, because Class B implements the A interface.
the so-called interface-oriented programming can reduce the coupling between programs, refers to the specific call at the interface is carried out, does not depend on the specific class, in a s = new B;, B can be arbitrarily implemented interface A of other classes replaced.
in the spring IOC, interface programming reduces the coupling between classes and is well represented, suggesting that you learn by the way, to deepen your understanding.
 
 

Interface-oriented programming is oriented to abstract programming.

For example, the example that your teacher said
A is an interface (an interface is abstract), B is a class (The resulting class object is specific).
A s=new B;
S This object has all the methods specified in a interface (class B is mandatory to be implemented).
So c,d, E, Class F can also implement a interface,
If you want to replace the c,d, E, F is very simple, call time or use a interface to specify which methods.

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.