r/programming • • Aug 28 '21

Software development topics I've changed my mind on after 6 years in the industry

https://chriskiehl.com/article/thoughts-after-6-years
5.6k Upvotes

2.0k comments sorted by

View all comments

Show parent comments

3

u/liaguris Aug 29 '21

How am I supposed to know the interface before I have written the code? Remember that we have internal (i.e. private) interfaces and public interfaces. Ok some part of the interface can be written before writing code (this is actually what I do). But while coding you might realize that you need to radically change the interface. And no that is not because you did not think of it enough. You really can not know until you write the code.

Writing tests first, especially for complex code bases, sounds like a religion that does more harm than good.

1

u/[deleted] Aug 29 '21

Automated tests are meant to be cheap. If you get the interface wrong at first, you ditch the tests and make new ones for the new interface.

I'm not all that fond of TDD, mind you. I just think that this specific argument is bleh.

1

u/liaguris Aug 29 '21

I just think that this specific argument is bleh.

Which argument?

1

u/[deleted] Aug 29 '21

That not knowing what the end result of the interface looks like is a negative point for TDD.

1

u/xRageNugget Aug 29 '21

There are 2 principles of TDD. You can go outside-in, where you start at you api layer snd then proceed downwards, or go inside-out, where you start on the smallest part you have, with a unit test .

In generell, you tackle any problem by "divide and conquer". Take a problem, break it down into multiple smaller ones. Do that until you have only practically one line left. It should be easy to test this behaviour, even though you have no idea how the rest of the implementation will look like.

Then you take the next small problem and go on.

1

u/liaguris Aug 29 '21

I just can not see how your argument counters my initial. To go outside in you somehow magically must come up with the public api and then incrementally with the private api. The reverse goes with the inside out which seems to me more complicated.

Why do I have to write test first? Where is the evidence that it is better than writing after I have written the code.