C
chrislewis
Hello group,
I was having a Monday refactoring sweep through some code and came
across this line:
URL resourceUrl = this.getClass().getClassLoader().getResource
(resourceName);
The class this lives in is perfectly small and single-minded, but as
I'm reading through Clean Code my eyes are a bit more on edge.
According to what Clean Code says about the Law of Demeter, it seems
like this is Bad Thing, as I'm calling a method on an object yielded
through chained calls (not to mention the class loader could be
considered a global resource). I'd like to hear what your opinions are
on this, and if it is indeed a violation of the LoD, how can one
access resources on the classpath in a "clean" manner?
I was having a Monday refactoring sweep through some code and came
across this line:
URL resourceUrl = this.getClass().getClassLoader().getResource
(resourceName);
The class this lives in is perfectly small and single-minded, but as
I'm reading through Clean Code my eyes are a bit more on edge.
According to what Clean Code says about the Law of Demeter, it seems
like this is Bad Thing, as I'm calling a method on an object yielded
through chained calls (not to mention the class loader could be
considered a global resource). I'd like to hear what your opinions are
on this, and if it is indeed a violation of the LoD, how can one
access resources on the classpath in a "clean" manner?