关联关系与依赖关系的区别

一、语义上:

关联关系:

A has a(knows a) B

依赖关系:

A uses a B

二、代码上:

关联关系:

package facade;

/**
* @author Administrator
* @version 1.0
* @created 11-十月-2015 18:42:05
*/
public class A {

public B m_B;(or public B * pm_B)

public A(){

}

public void finalize() throws Throwable {

}

}

依赖关系:

package facade;

/**
* @author Administrator
* @version 1.0
* @created 11-十月-2015 18:44:06
*/
public class A {

public A(){

}

public void finalize() throws Throwable {

}

/**
*
* @param obj
*/
public int process(B m_B(or B * pm_B)){
return 0;
}

}

posted @ 2015-10-11 18:45  兵形东华  阅读(415)  评论(0编辑  收藏  举报