5 ms·
One concern I have with designing for testability (which often means, designing for ease of unit testing) is that everything becomes a abstract interface. Wher
by RcouF1uZ4gsC 3y ago
One concern I have with designing for testability (which often means, designing for ease of unit testing) is that everything becomes a abstract interface.
Whereas before you might have
void Foo(){
Bar();
}
void Bar(){
Baz();
}
void Baz(){
}
Where Bar and Baz only really have a single implementation
This is fairly easy to grok and debug.
You end up with
void Foo(BarInterface* bar, BazInterface* baz){
bar->Bar(baz);
}
Now you have a lot more moving parts. If you have a problem with Foo, now you need to try to find out who all implements the interfaces and which implementation is being passed to.
Of course, after a while people get tired of passing in these interfaces and come up with some kind of "automated" dependency injection framework, which then triples the complexity.
- mrkeen 3y ago> If you have a problem with Foo If you have a problem with Foo, you instantiate a Foo inside FooTest, and then feed it problematic input. You can't instantiate a Foo inside FooTest unless you can instantiate a Foo and a Bar. Foo could be a clock whose time-of-day you can't control, and Bar could be a database that you can't instantiate.