三层优化
1.加入接口
建议面向接口开发:先接口再实现类
—service、dao加入接口
—接口与实现类的命名规范
接口:interface, 起名 I实体类Service IStudentService
IStudentDao
实现类:implements 起名 实体类ServiceImpl StudentServiceImpl
StudentDaoImpl
接口命名:I实体类层所在的包名 例如: IStudentService、IStudentDao
接口所在的包: xxx.service xxx.dao
实现类命名:实体类所在包名Impl 形如: StudentServiceImpl、StudentDaoImpl
实现类所在的包: xxx.service.impl xxx.dao.impl
以后使用接口/实现类时,推荐写法:
接口 x=new 实现类() 《——多态的表现方式
面向接口开发
形如:IStudentDao studentDao=new StudentDaoImpl();
2.DBUtil 通用的数据库帮助类
帮助类一般写在 xxx.util包
优化三层
最新推荐文章于 2024-07-29 08:46:50 发布