mercredi 10 août 2016

cyclic dependency in c#, is it design smell?

class A
{
    public B b { get; set; }
    public void Ma()
    {
        b.Mb();
    }
}

class B
{
    B()
    {
        A a = new A();
        a.b = this; 
    }
    public void Mb()
    {
    }
}

in given scenario, I am creating object of class A in class B and passing current object of B in A.
I have 3 questions
1. Is there cyclic dependency between both classes?
2. Is it design smell?
3. if it is design smell, how to resolve it?

Aucun commentaire:

Enregistrer un commentaire