Say you have a class named AbcClass
.
If AbcClass
depends on AnotherClass
, and AnotherClass
eventually needs to make a network call (e.g. to S3, Databse, GIS, some other party), then don't instantiate AnotherClass
inside AbcClass
.
AnotherClass
should be injected into the constructor of AbcClass
.
Say AnotherClass
is instantiated inside AbcClass
.
When you write a test for AbcClass
, AnotherClass
will inevitably make a network call.