DAO中为什么要让类实现一个接口,写接口的作用是什么
DAO中为什么要让类实现一个接口,写接口的作用是什么
感觉这个接口没多大作用
示例代码如下:
public interface ArticleDAO { public int insertAricle(String id); public boolean deleteArticle(String id); public boolean updateArticle(Article art); public Article findArticle(String id);}
public class ArticleDAOImp implements ArticleDAO{ private Connection conn; public ArticleDAOImp(Connection conn) { this.conn = conn; } public int insertAricle(String id) { throw new UnsupportedOperationException("Not supported yet."); } public boolean deleteArticle(String id) { throw new UnsupportedOperationException("Not supported yet."); } public boolean updateArticle(Article art) { throw new UnsupportedOperationException("Not supported yet."); } public Article findArticle(String id) { throw new UnsupportedOperationException("Not supported yet."); } public void releaseConnection(){ try{ this.conn.close(); }catch(Exception e){ e.printStackTrace(); } }}