Skip to content

Method References

Breaking static dependencies using Java 8 lambdas

Static dependencies are usually bad , because that dependencies are based on the class level and class objects can not be replaced at runtime in contrast to object instances. That’s why static dependencies are usually a pain if it comes to tests. When you want to write a unit test you usually want to mock the dependent objects, but you can’t do that if the dependent object is a class. Timing is for example hard to test, because it is based on the static call to System.currentTimeMillis(); and the result of currentTimeMillis changes all the time. Of course it does, because it’s the nature of time but that makes it also hard… Read More »Breaking static dependencies using Java 8 lambdas

GDPR Cookie Consent with Real Cookie Banner