Created
August 13, 2015 15:54
-
-
Save patrykpoborca/fb9c9f3ee182e76f1c1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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