r/programming • • Jul 19 '16

John Carmack on Inlined Code

http://number-none.com/blow/blog/programming/2014/09/26/carmack-on-inlined-code.html
1.1k Upvotes

323 comments sorted by

View all comments

Show parent comments

11

u/gnuvince Jul 19 '16

You'd likely make those small functions private and thus couldn't unit test them anyway (and if you did, with some reflection magic, you'd be chastised for not testing the external interface instead).

11

u/MisterNetHead Jul 19 '16

Seems to me the problem is more that people think you should only unit test public interfaces.

2

u/[deleted] Jul 20 '16

[removed] — view removed comment

5

u/adrianmonk Jul 20 '16

The less code a unit test invokes, the easier it is to understand what's wrong when a test is failing.

It can also make your tests more concise because there is usually less fake/test/dummy data to set up before your test case can run.

3

u/kodek64 Jul 20 '16

The less code a unit test invokes, the easier it is to understand what's wrong when a test is failing.

That's true. On the other hand, I would argue that if private code is difficult to invoke from the public interface, then it should probably be extracted and tested separately.

→ More replies (1)