1、基本介绍
依赖关系(Dependence),只要是在类中用到了对方,那么他们之间就存在依赖关系。如果没有对方,连编译都通过不了。
2、应用实例
1)代码演示:
public class PersonServiceBean {
private PersonDao personDao;
public void save(Person person) {
}
public IDCard getIdCard(Integer personId) {
return null;
}
public void modify() {
Department department = new Department();
}
}
public class PersonDao {}
public class Person {}
public class IDCard {}
public class Department {}
2)UML 类图:
3、小结
1)类中用到了对方
2)如果是类的成员属性
3)如果是方法的返回类型
4)是方法接收的参数类型
5)方法中使用到