dimanche 17 juillet 2022

What if i instantiate all the classes in one function and call that function every where?

if i have n classes and instantiate all the classes in one function, what are the major drawbacks for this . ex bellow :-

class A{}
class B{}
class C{}
.
.
class Z{}



main(){
new classA()
new classB()
.
.
.
new classZ()

}

and where ever I need any class. I just call the main method. I know that this is bad , but and IOC should be used , but what are the major disadvantages of using this ?

Aucun commentaire:

Enregistrer un commentaire