關聯關係與依賴關係的區別

兵形東華發表於2015-10-11

一、語義上:

關聯關係:

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;
}

}

相關文章