今天主要是刷网课来着
记了不少笔记如下
三层优化
1.加入接口
建议面向接口开发:先接口-再实现类
--service、dao加入接口
--接口与实现类的命名规范
接口:interface, 起名 I实体类Service IStudentService
IStudentDao
实现类:implements 起名 实体类ServiceImpl StudentServiceImpl
StudentDaoImpl
接口: 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层的代码量
帮助类 一般建议写在 xxx.util包
A
{
a(){
B.connection
}
}
B
{
static Connection connection =..
b{
}
}
方法重构: 将多个方法 的共同代码 提炼出来,单独写在一个方法中,然后引入该方法即可
a()
{
..
c();
..
}
b()
{
..
c();
..
}
c()
{
[..
..
...
..]
}
Web调试:
与java代码的调试 区别:启动方式不同
index.jsp ->index_jsp.java ->index_jsp.class
jsp->java->class
jsp翻译成的Java 以及编译后的class文件 存在于tomcat中的work目录中