+ Start a Discussion
ciccic 

class A uses class B which uses class A - is this intended to be allowed?

public class A {
    public void MethodA() {
         /*do something*/
         B.MethodB();
  }
}
 
public class B {
  public methodB() {
       /*do something else*/
       A.MethodA();
  }
}
 
NB These two classes are in seperate files so complied seperately.
 
Not a very useful bit of code - but one that illustrates a question.  Is this type of thing allow in Apex?  There are more useful examples I could give and it is a very useful construct.  Without it you have to be careful to design classes in a strict hierarchy.
 
If you try it you find that the compiler will allow it.  The classes will run and work.  You get a problem if you try to deploy it or if one of the classes is detected as needing recompilation on use.   The underlying Apex Code system does not seem to recognise mutual dependancy - only strict tree-like dependancies.  Deployment or recompilation of such structures frequently fail.
 
Is it intended that Apex Code supports this?  If so can the compiler / dependency checker be made to work?  It is a useful structure to permit.  Thanks.
 
 
 
 
 

Message Edited by cic on 11-08-2007 10:57 PM

Message Edited by cic on 11-08-2007 11:06 PM