Sometimes, when you make a class, it directly instantiates an object to use in its methods. For example:
public void myFunc()
{
MyType object = new MyType();
object.doSomething();
this.thingy = object.getSomething();
}
This is generally viewed as bad, since you’re tightly coupling your class to the instantiated one. “But,” you say, “I know that I will never use any other class, and I certainly don’t want users of the class to be supplying alternatives to use.” These concerns are mostly valid, but they leave out a very important thing to pay attention to: testing. Continue Reading



