File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Class A uses Class B Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Class A uses Class B" Watch "Class A uses Class B" New topic

Class A uses Class B

Simon Xu
Ranch Hand

Joined: Aug 16, 2000
Posts: 235
I got few answer from other forum. Hope this forum can help me on this.
There are several cases for "class A directly uses B". My question is there are any other cases besides the following cases? Thanks.
1) if class A refers to class B as a data member, local
variable, argument, data cast, or if A inherits from B or if
A implements interface B, then A uses B. Classes A and B
interact if either A uses B or B uses A.
2)A can directly refer class B's static methods (or data members). B does not have to be a data member or local variable or argument of A
3) instanceof B
4)Inner class: if A is an inner class of B, then objects that are instances of A generally retain the ability to access the members of outer class B. In this case, B does not have to be the data member etc of A
5) Anonymous class
6) Conditional compilation
Doug Dunn
Ranch Hand

Joined: Aug 03, 2003
Posts: 66
It is not at all clear what you are asking here. Is this a "first active use" question? Perhaps it would help if you explained the problem you are trying to solve.

Download a copy of <a href="" target="_blank" rel="nofollow"><i>"Mastering The Fundamentals of The Java Programming Language"</i></a>
Simon Xu
Ranch Hand

Joined: Aug 16, 2000
Posts: 235
In fact, we are doing reseach on change propagation on java program. For example, during maintenance, if we add one class or one method to the system, it might impact other parts. How do we find those impacted components at minimum effort. We need to do static analysis to find all the impacted components. That is why we are looking for all the cases that class A (or object A) uses class B (object B). Of course, we will iterately do that, thus we just need to see A directly using B.
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Moving this to the OO, Patterns, UML and Refactoring forum where they like to talk about this type of thing...

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: Class A uses Class B
It's not a secret anymore!