三层优化

三层优化
1.加入接口
建议面向接口开发:先接口-再实现类
--service,dao加入接口
--接口与实现类的 命名规范
接口: interface 起名 I实体类Service IStudentService

实现类: implements 起名 实体类ServiceImpl StudentServiceImpl

接口: I实体类层所在包名 IStudentService、IStudentDao
接口所在的包:xxx.service xx.dao
实现类: 实体类所在包名Impl StudentServiceImpl、StudentDaoImpl
实现类所在的包:xxx.service.impl xx.dao.impl

以后使用接口/实现类时,推荐写法:
接口 x=new 实现类();
IStudentDao studentDao=new StudentDaoImpl();
2.DBUtil 通用的数据库帮助类,可以简化Dao层的代码量

帮助类
方法重构:将多个方法的共同代码提炼出来,单独写在一个办法中

原文地址:https://www.cnblogs.com/mayouyou/p/13090160.html