mardi 25 août 2015

Circular Dependency in java- Design

How to prevent circular dependency, any design patterns??,otherwise it will cause stack overflow. I was asked to redesign this.

class A {
    static void method(){
        B.method(); 
    }
    public static void main(String args[]){
        method();
    }
}

class B {
    static void method(){
        A.method(); 
    }
}

Aucun commentaire:

Enregistrer un commentaire