Re:Write tests. Not too many. Mostly integration
by quickthrower2 on Friday October 27, 2017 @06:31AM
(#15567116)
How is static code different from other noninjected code, like stuff in a method. Taken to the logical conclusion we'll have thousands or classes full of max 2 operations per method.
[ Parent
| on HN ]
Re:Write tests. Not too many. Mostly integration
by hacker_9 on Friday October 27, 2017 @06:41AM
(#15567150)
How many static classes are your methods using? And what is the problem with injecting this stuff at the top of the class instead? If you plan to write tests, you have to control your dependencies, and DI is the simpliest way to do that.
Re:Write tests. Not too many. Mostly integration
by quickthrower2 on Friday October 27, 2017 @03:51PM
(#15571649)
Because these tests become too detached from reality if you inject everything. A silly example to make the point:
IAdder { double Add(double a, double b) }
Test:
car mockAdder = ... // Mock 1+1=2 etc.
Re:Write tests. Not too many. Mostly integration
by marcus_holmes on Friday October 27, 2017 @09:26AM
(#15568018)
um... yes... this is actually what "pure" OO involves. The only reason we don't do this is because it's a nightmare to manage.