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.