/* Generally, the interface is useless. You can add, delete, modify, and query an implementation class. The processed items can be divided into multiple packages. * Similar to com. user. *; COM. group. *; COM. role. *; ** the general practice is as follows: */public class sportscar {public void save (CAR) {}; public sportscar Update () {}; public int Delete () {}; public... {}} public class mailcar {public void save (car) {}; public mailcar Update () {}; public int Delete () {}; public... {}} public class synchronized ECAR {public void save (car) {}; public synchronized ECAR Update () {}; public int Delete (){ }; Public... {}... // then, when many operations are found to be identical, the interface is required. Public interface ICAR {public void save (car) throws exception; Public synchronized ECAR Update () throws exception; Public int Delete () throws exception; public... {} throws exception} public class implements ecarimpl implements ICAR {implements method... {};} public class mailcarimpl implements ICAR {implements method... {};}// the advantage of doing so is that you only need to modify the interface when restructuring the method. // If the DAO method is implemented using an interface. Public interface ipolicecardao {void save (car) throws exception;} public interface imailcardao {public int Delete () throws exception;} public class caropraeteimpl implements extends ecardao, mailcardao {public void save (car ){...} public int Delete (){...}} /** then the program can be loosely coupled */public class caropraeteservice {public imailcardao MC; Public void setmc (imailcardao MC) {This. MC = MC;} public void save (Car car) {// The save method is called here. So the specific implementation method. This class is unknown. This is what I think is the so-called loose coupling, right? // This. MC = new caropraeteimpl (); the interface is initialized in this way. This. MC. Save (CAR) ;}// this is also the case when the following action is called. Action does not know what the serviceinterface class has done. // All corresponding service interfaces can be implemented by a class. In this way, the serviceimpl implementation class will not be known when there are internal methods to process data. // Summary: interfaces are secure, loosely coupled, and easy to modify.
This is my opinion. I don't know. If you have any questions, add qq290010324.
Personal Understanding interface meaning