From http://www.cnblogs.com/ggjucheng/archive/2012/12/04/2802311.html
English from http://docs.oracle.com/javase/tutorial/java/IandI/nogrow.html
Consider that you have developedDoit
Interface
Public interface doit {void dosomething (int I, double X); int dosomethingelse (string S );}
Suppose you wantDoit
Add the third method, so the interface changes:
Public interface doit {void dosomething (int I, double X); int dosomethingelse (string S); Boolean diditwork (int I, double X, string S );}
If this change is made, all the old interfaces will be inherited.Doit classes all have errors because they do not fully implement this interface. Depends on this interfaceProgramMembers will protest loudly.
Try to make all the functions of your interface fully foreseen from the very beginning. This is often impossible. You may need to create more interfaces. For example, you can create a doitplus interface ExtensionDoit
:
Public interface doitplus extends doit {Boolean diditwork (int I, double X, string S );}
Now, yourCodeYou can choose to continue using the old interface or upgrade to the new interface.