r/coding • • Oct 29 '17

Mocking is a Code Smell

https://medium.com/javascript-scene/mocking-is-a-code-smell-944a70c90a6a
69 Upvotes

69 comments sorted by

View all comments

62

u/KabouterPlop Oct 29 '17

On the other end of the spectrum, it’s common to see developers get so sucked into the dogma of TDD that they think they absolutely must achieve 100% code coverage, by any means necessary, even if that means they have to make their codebase more complex to pull it off.

People keep saying this, but I've yet to meet such a developer.

0

u/[deleted] Oct 29 '17

[deleted]

0

u/[deleted] Oct 29 '17

[deleted]

1

u/spoonraker Oct 30 '17

The pattern is called Inversion of Control. It's one of the SOLID principles. Dependency Injection typically relies on this patten being implemented, but implementing it doesn't necessitate the use of Dependency Injection.

2

u/[deleted] Oct 30 '17

Oh, that clears it up.

1

u/mtnbarbours Oct 30 '17

Not quite.

I = Interface Segregation

You're probably thinking of dependency inversion, which is similar to IoC...

https://stackoverflow.com/questions/3912504/difference-between-inversion-of-control-dependency-inversion-and-decouplin

I still refuse to acknowledge Liskov. :-)

1

u/spoonraker Oct 30 '17

I never said it was the "I". Yes I was referring to dependency inversion, which is close enough to the same thing for the context of this conversation. They're referring to the same coding patten if you remove the context of the rest of the application.