Skip to content

Instantly share code, notes, and snippets.

@patrykpoborca
Created August 13, 2015 15:54
Show Gist options
  • Select an option

  • Save patrykpoborca/fb9c9f3ee182e76f1c1c to your computer and use it in GitHub Desktop.

Select an option

Save patrykpoborca/fb9c9f3ee182e76f1c1c to your computer and use it in GitHub Desktop.
public class MyDependency {}
public class MyClass {
private MyDependency dependency;
public MyClass(MyDependency myDependency){
this.dependency = myDependency;
}
}
public class AnotherClass{
private final MyClass myClass;
//bad implementation, as you can see we are creating two new instances of objects that this class depends on
public AnotherClass(){
this.myClass = new MyClass(new MyDependency());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment