samedi 30 janvier 2016

Transfering an object over multiple clase instances

I am thinking of a optimum design pattern which I can use for transfer objects to the methods in different classes other than passing them as arguments.

class A{
}

class B{
   public A a;
   public B()
    {
       a = new B();
    }
}

class C
 {
    public void c()
      { 
         //need to access "a" of class B other than passing "a" as argument; 
      }
 }

Here, "a" in class A attribute need to be accessed in many other class methods, Is there any optimum design pattern or any possible way other than passing this object (a) as arguments.

Aucun commentaire:

Enregistrer un commentaire