jeudi 7 février 2019

Is this the good class design practice in Java?

public class OneClass {
        private AnotherClass anotherClass = new AnotherClass();

        private void doOneJob(){
            anotherClass.doOtherJob();
        }
    }

In the above code, AnotherClass is instantiated and held as a class variable of OneClass.

  • What are the consequences of this design?
  • Is it a good practice?
  • Will this support unit testing?

Aucun commentaire:

Enregistrer un commentaire