< Return to Video

Is TDD dead?

  • 0:01 - 0:03
    Hey, everyone.
  • 0:03 - 0:05
    I am David Heinemeier Hansson.
  • 0:05 - 0:08
    I'm here with the Martin Fowler and Kent Beck
  • 0:08 - 0:13
    to talk about "is TDD dead?" as the topic.
  • 0:13 - 0:20
    Coming off keynote I did at Rails conference and subsequent articles I posted on the blog.
  • 0:20 - 0:24
    I had chance to talk with both Kent and Martin
  • 0:24 - 0:27
    one on one in the days that followed.
  • 0:27 - 0:30
    and we got to discussed a bunch of these issues
  • 0:30 - 0:36
    and I got to clarify some thoughts and definitions that I had in my head
  • 0:36 - 0:40
    and got a lot wiser about where both Martin and Kent are on the issue
  • 0:40 - 0:44
    and Kent suggested that, "Hey. Maybe we should share that with world."
  • 0:44 - 0:47
    So that's what we're doing now.
  • 0:47 - 0:52
    I know bunch of people have been expecting to this is gonna be a big???
  • 0:52 - 0:54
    there'll be no boxing.
  • 0:54 - 0:59
    We'll explore bunch of definitions and problems and patterns we've seen.
  • 0:59 - 1:03
    and what's work for us individually and go from there
  • 1:03 - 1:07
    But to get started, I thought
  • 1:07 - 1:11
    I just run over brief recap of the problems that I've seen with TDD
  • 1:11 - 1:14
    use that to kick off the discussion
  • 1:14 - 1:19
    and really three major points that all focus on this discussion.
  • 1:19 - 1:24
    The first is the definition of TDD and its components
  • 1:24 - 1:26
    specifically unit testing.
  • 1:27 - 1:30
    I know the TDD and unit testing are certainly not the same thing
  • 1:30 - 1:34
    but TDD's often used to drive unit test
  • 1:34 - 1:37
    and as I was looking through
  • 1:37 - 1:41
    issues I've been in the Rails world around TDD
  • 1:41 - 1:44
    a lot of that came down to the definition of unit testing.
  • 1:44 - 1:47
    that people were defining unit testing as
  • 1:47 - 1:50
    you can't have collaborators
  • 1:50 - 1:51
    you can't touch the databases
  • 1:51 - 1:53
    you can't touch the filesystem
  • 1:53 - 2:01
    goal was to have a suite of unit tests so fast that they could complete in a blink of an eye.
  • 2:01 - 2:03
    I've seen arguments of
  • 2:03 - 2:08
    if it takes more than 300 milliseconds to complete the entire suite then it's way too slow.
  • 2:08 - 2:09
    I can't use it for anything.
  • 2:09 - 2:14
    and that just wasn't matching my useful definition of unit testing
  • 2:14 - 2:17
    and it wasn't matching what I was trying to get out of it.
  • 2:17 - 2:23
    and frankly I wasn't get anything useful out of unit tests that weren't talking to any collaborators.
  • 2:23 - 2:29
    Second, which follows from that is driving your architecture through Mocks.
  • 2:29 - 2:34
    If you want everything in your test suite to be so super fast
  • 2:34 - 2:37
    well obviously you have to talk to mocks
  • 2:37 - 2:38
    you can't talk to anything slow
  • 2:38 - 2:41
    and you can't talk to many layers at once
  • 2:41 - 2:47
    which leads to a mock sort of heavy and enabling architecture
  • 2:47 - 2:52
    repositories and hexagonal pattrerns
  • 2:52 - 2:57
    and all these other things that makes very easy to stuff and mock your way out of everything
  • 2:57 - 3:01
    and turn every test you could imagine into unit tests
  • 3:01 - 3:03
    MVC framework as I work with rails
  • 3:04 - 3:09
    the controller, "Oh, no problem. Just stuff out everything talking to the view"
  • 3:09 - 3:13
    "talking to the model and then that's gonna be great."
  • 3:13 - 3:16
    I was not seeing that being very great at all
  • 3:16 - 3:20
    the key point what I thought
  • 3:20 - 3:22
    this is test induced damage
  • 3:22 - 3:30
    that the architect is actually suffering damage from this drive towards unit testing all the things
  • 3:30 - 3:36
    and that the unit testing all the things is coming through the TDD pipe.
  • 3:36 - 3:41
    And then finally this sort of ..... TDD
  • 3:41 - 3:43
    is the read green refactor loop.
  • 3:43 - 3:47
    And that was more of, sort of personal thing.
  • 3:47 - 3:52
    We can all have our own personal preferences and how we develop things
  • 3:52 - 3:58
    in TDD red-green refactor seemed .... more of mandate
  • 3:58 - 4:04
    I never dealt with that for the bulk of the work that I do
  • 4:04 - 4:08
    at certain locations at work and at certain locations that flow was good
  • 4:08 - 4:13
    but I felt like there there's tons of code that I was writing were red green refactor
  • 4:13 - 4:15
    just not an enjoyable of way to do it.
  • 4:15 - 4:18
    and I didn't feel like I was going to a better place by going through that
  • 4:18 - 4:25
    So those sort of the three top-line problems that I think with the TDD
  • 4:25 - 4:27
    Let's sort of the open conversation up
  • 4:28 - 4:34
    and have Martin and Kent chime in perhaps one at a time
  • 4:34 - 4:36
    What is unit test?
  • 4:36 - 4:39
    What's useful definition of unit test?
  • 4:39 - 4:44
    What's useful definition of unit test and how most people currently defining it in you guys' view.
  • 4:44 - 4:47
    Well, I propose
  • 4:47 - 4:49
    in order to understand something
  • 4:49 - 4:52
    I often find it useful to know how it came about.
  • 4:52 - 4:58
    And the style of unit testing we familiar with is basically all Kent's fault.
  • 4:58 - 5:03
    Right? Because Kent did the framework, XUnit frameworks
  • 5:03 - 5:05
    whole push through extreme programming
  • 5:05 - 5:07
    so maybe we start with that
  • 5:07 - 5:11
    where those source of this style of unit testing come from.
  • 5:11 - 5:14
    You're the guy. You explain it.
  • 5:14 - 5:20
    Can you hear me?
  • 5:20 - 5:23
    Yep.
  • 5:23 - 5:31
    So when I was a kid
  • 5:31 - 5:33
    I would read books about programming
  • 5:33 - 5:35
    I was just fascinated by programming.
  • 5:35 - 5:38
    I'm talking about nine, ten, eleven years old
  • 5:38 - 5:40
    and my dad was a programmer
  • 5:40 - 5:42
    so there're lots of books about programming around.
  • 5:42 - 5:48
    And he had a book and I would read I didn't understand anything
  • 5:48 - 5:53
    but I was just sorta compulsively reading these books
  • 5:53 - 5:55
    cause I found the whole topics fascinating
  • 5:55 - 5:59
    there was a book that said, "Here's how you program."
  • 5:59 - 6:05
    "You type in the output tape that you expect your program to produce given some input tape"
  • 6:05 - 6:13
    "And in programming is, you just write program and tell it produces the output tape that you expected."
  • 6:13 - 6:19
    So that was kind of fixed way back in my brain as the flow of programming.
  • 6:19 - 6:25
    And it wasn't until after I had been testing for a while
  • 6:25 - 6:31
    that already come up with the first version of SUnit, the Smalltalk testing framework
  • 6:31 - 6:33
    that was the precursor to JUnit.
  • 6:33 - 6:41
    and I remember this idea of writing the test before writing the code
  • 6:41 - 6:42
    which makes no sense, right?
  • 6:42 - 6:45
    the test is gonna fail and you want the test succeed.
  • 6:45 - 6:49
    so why would you write it when you knew it was gonna fail?
  • 6:49 - 6:51
    So I just tried it.
  • 6:51 - 6:59
    One of my heuristics is, "If an idea is obviously bad, find the cheap way to try it
  • 6:59 - 7:03
    because if it turns out it's not bad then it's really interesting
  • 7:03 - 7:05
    if you have a good idea and it's obviously good
  • 7:05 - 7:08
    somebody else's probably tried it before.
  • 7:08 - 7:13
    So, I just figured I'd try and I think I built stack at first time.
  • 7:13 - 7:16
    and it worked really really for me.
  • 7:16 - 7:26
    i think there's aspects of my personality that make this kind of peicemeal style work really well
  • 7:27 - 7:33
    I have a lot of anxiety and I tend to get overwhelmed by big problems
  • 7:33 - 7:38
    and for me TDD solves those problems.
  • 7:38 - 7:44
    Even if I don't know how to implement something I can almost always figure out how to wright tests for it
  • 7:44 - 7:50
    and if I can't figure out how to write a test for it, I have no business in programming in the first places.
  • 7:50 - 7:54
    So, that's how got into it.
  • 7:54 - 7:58
    And it was definitely ground up
  • 7:58 - 8:05
    that is, I started with small green problems and gradually work my way to larger green problem."
  • 8:05 - 8:09
    Go ahead.
  • 8:09 - 8:14
    I was thinking about this on reflecting back on our early days together
  • 8:14 - 8:19
    and if I recall correctly when we began working
  • 8:19 - 8:22
    ??? using extreme programming ???
  • 8:22 - 8:25
    we did the testing very strongly from the beginning
  • 8:26 - 8:27
    but it wasn't test first at beginning.
  • 8:27 - 8:31
    I've got this memory of you standing up and saying
  • 8:31 - 8:37
    "The stories are not done until the codes're written and the tests're written and the tests are passing.
  • 8:37 - 8:41
    So we have the notion that you delivered at the end of it
  • 8:41 - 8:43
    increment of functionality with code and tests together
  • 8:43 - 8:46
    but test first didn't actually followed till later.
  • 8:46 - 8:53
    I can't remember when that came because it seemed gradually appeared.
  • 8:53 - 8:58
    but I feel that at that very beginning the focus was on the tests.
  • 8:58 - 9:00
    on the tests with that but that's the first as it were
  • 9:00 - 9:06
    so I think one of the fundamental question is
  • 9:06 - 9:10
    as a programmer do you deserve to feel confident?
  • 9:10 - 9:18
    I certainly grew up in culture that didn't encourage that.
  • 9:18 - 9:21
    You know, you write some stuff and just hope it works
  • 9:21 - 9:23
    somebody else would tell you whether they thought it worked.
  • 9:24 - 9:29
    and you go home on Friday and just think
  • 9:29 - 9:31
    "Oh god. I just hope I didn't break something."
  • 9:31 - 9:38
    and so I think the going a step back from TDD or automated testing
  • 9:38 - 9:41
    "do you deserve to feel the confidence?"
  • 9:41 - 9:42
    "can you sleep at night?"
  • 9:42 - 9:44
    knowing that your code works
  • 9:45 - 9:47
    I think the answer should be Yes for programmer.
  • 9:47 - 9:51
    So if we agree on that then we can talk about how to achieve that.
  • 9:51 - 9:53
    TDD is one way to achieve that.
  • 9:53 - 9:55
    There's lots of other ways.
  • 9:55 - 9:59
    I think that it's a great point because
  • 9:59 - 10:02
    one of the things that really got me into programming was
  • 10:02 - 10:03
    was Ruby.
  • 10:03 - 10:06
    Right. So I've been programming before Ruby but
  • 10:06 - 10:12
    this language that has a very specific mission statement.
  • 10:12 - 10:14
    Programmer Happiness
  • 10:14 - 10:17
    Right. So I think those two are related
  • 10:17 - 10:23
    the programmer happiness is certainly related to feeling confident in your code
  • 10:23 - 10:25
    and confident in making changes to it
  • 10:25 - 10:27
    and confident that's going to work
  • 10:27 - 10:29
    But it's only one part of that picture
  • 10:29 - 10:32
    and early days Martin described were
  • 10:32 - 10:37
    "Oh. You're not done until you also have tests for piece of functionality.
  • 10:37 - 10:38
    I'm completely on board with that. Right?
  • 10:38 - 10:40
    Where I'm not on board is that
  • 10:41 - 10:45
    that whole feeling of feeling great about your development style
  • 10:45 - 10:49
    feeling programmer happiness as Matz would always put it.
  • 10:49 - 10:53
    Just I wasn't getting that from TDD, right?
  • 10:53 - 10:56
    So maybe that's some of the patterns we talked about
  • 10:56 - 11:00
    different people with different brain style, right?
  • 11:00 - 11:02
    Why do some people enjoy Python?
  • 11:02 - 11:04
    Why do some people enjoy Ruby?
  • 11:04 - 11:09
    and even harder for me to comprehend how some people enjoy Java.
  • 11:09 - 11:13
    But but we sort of have different ways of looking at things
  • 11:13 - 11:15
    and feeling good about them.
  • 11:15 - 11:19
    and what I was finding just from the red green refactor flow
  • 11:19 - 11:23
    was that the whole notion of writing to test first and seeing that fail
  • 11:23 - 11:26
    and doing that for every piece of code before I move forward
  • 11:26 - 11:29
    was just not natural
  • 11:29 - 11:32
    because a natural you can overcome just by familiarity
  • 11:32 - 11:38
    but even through familiarity it was just not a pleasurable flow
  • 11:38 - 11:44
    and I think that's where a lot of the explosive debate comes from
  • 11:44 - 11:52
    to some people writing your thesis first and filling in the implementation with that works really well.
  • 11:52 - 11:53
    That's exactly how their brain operates
  • 11:53 - 11:57
    For other people, me included, it doesn't work like that.
  • 11:57 - 12:02
    It's much more tactile experience that I actually have to sit in and write it out
  • 12:02 - 12:03
    that's how I think through it
  • 12:03 - 12:09
    I don't think through it by proposing hypothesis up first and then try to fill it in.
  • 12:09 - 12:12
    I think through it by writing it out
  • 12:12 - 12:18
    If I can't write test first I have no business writing it.
  • 12:18 - 12:23
    That's I totally understand how that you can arrived at
  • 12:23 - 12:25
    It's just not at all how I feel about it.
  • 12:25 - 12:30
    I have a hard time writing a test forward, if I don't see it first, right?
  • 12:30 - 12:33
    SO you have sort of these some people like it from
  • 12:33 - 12:36
    going through the test
  • 12:36 - 12:38
    and other people like going to the test.
  • 12:38 - 12:39
    I think .
  • 12:39 - 12:42
    certainly important to realize we're both getting to same place
  • 12:42 - 12:45
    getting to fell confident about the code
  • 12:45 - 12:47
    confident making the changes to the code
  • 12:48 - 12:53
    that's the part I'm not a fan of tying these two things together
  • 12:53 - 12:54
    I'm not a fan of tying
  • 12:54 - 12:57
    oh you just have to be confident to TDD
  • 12:57 - 12:59
    which, I know you're not doing, right?
  • 12:59 - 13:02
    TDD is one path of getting to that place
  • 13:02 - 13:05
    I've seen there're a lot of people are mistaken those two things
  • 13:05 - 13:07
    that you can't have confidence
  • 13:07 - 13:10
    you can't deliver incremental functionality with test
  • 13:10 - 13:16
    unless you go through this mandated well paid road of TDD
  • 13:16 - 13:22
    so, last night was hackathon at Facebook
  • 13:22 - 13:29
    and I have a project on a internal tool that I was working on.
  • 13:29 - 13:33
    and half of it I could use TDD for
  • 13:33 - 13:34
    and half of it I couldn't
  • 13:34 - 13:38
    so I had a big log that I wanted to process
  • 13:38 - 13:44
    and the entries in the log were not clearly specified anywhere
  • 13:44 - 13:47
    but I wanted to put them into a data structure
  • 13:47 - 13:52
    kind of funky new data structure
  • 13:52 - 13:56
    the data structure I could build with TDD is just fine
  • 13:56 - 13:59
    because I could break it down
  • 13:59 - 14:02
    ok, here's the main case
  • 14:02 - 14:03
    here's the corner cases
  • 14:03 - 14:06
    here's how I go from one to many
  • 14:06 - 14:08
    just nice sequence of tests
  • 14:08 - 14:13
    and I can get into real flow
  • 14:13 - 14:17
    just make one test work and the next one and the next one
  • 14:17 - 14:19
    so that feels a certain way to me
  • 14:19 - 14:23
    when I had to fiddle live data into it
  • 14:23 - 14:25
    it feels very different way
  • 14:25 - 14:28
    because I don't have that clear specification
  • 14:28 - 14:33
    I just have to run a few million log entries through this first
  • 14:33 - 14:34
    and see what blows up
  • 14:34 - 14:37
    so I put in logging
  • 14:37 - 14:40
    I put in exception handling
  • 14:40 - 14:45
    so any log entry that's kind of funky that isn't handle by the code
  • 14:45 - 14:47
    get saved some place
  • 14:47 - 14:54
    then I can't go back and look at those entries that I can't handle yet
  • 14:54 - 14:56
    and I can use them
  • 14:56 - 14:59
    but I can't write a test for it
  • 14:59 - 15:01
    because I don't even know what the inputs look like
  • 15:01 - 15:04
    and that feels different way to me
  • 15:04 - 15:09
    so with the parts of the code that I can use TDD for
  • 15:09 - 15:10
    I mean a real flow
  • 15:11 - 15:12
    write a test, make it work
  • 15:12 - 15:13
    write a test, make it work
  • 15:13 - 15:15
    ??? 12:30
  • 15:15 - 15:17
    I really like that feeling
  • 15:17 - 15:23
    the ones where I have to run on live ???
  • 15:23 - 15:24
    see what happens
  • 15:24 - 15:27
    I fee a lot more anxiety
  • 15:27 - 15:31
    but you know it's called work for reason
  • 15:31 - 15:37
    so I'm going to use the principles of double checking of regression testing
  • 15:37 - 15:39
    of short feedback loops
  • 15:39 - 15:43
    and try to get the shortest possible feedback loop
  • 15:43 - 15:46
    out of this unpredictable input that I'm getting
  • 15:46 - 15:51
    so I had to mix the two styles in one night
  • 15:51 - 15:52
    and it doesn't bother me
  • 15:52 - 15:59
    if I can play classical and jazz then I'm in a better position to make music for more people
  • 15:59 - 16:05
    but when I can reduce a problem to this sequence of tests
  • 16:05 - 16:08
    drive the solution from this sequence of test
  • 16:08 - 16:11
    it has special kind of feeling
  • 16:11 - 16:12
    for me it works really well
  • 16:12 - 16:16
    if I think back to how learned a ??? map
  • 16:16 - 16:17
    I always used these examples
  • 16:17 - 16:20
    you know there'd be some general
  • 16:20 - 16:23
    you know, prove this statement
  • 16:23 - 16:27
    and I think well, "what's an example of that"
  • 16:27 - 16:29
    and then I come up with a few examples
  • 16:29 - 16:32
    and I convince myself either the statement was true or that wasn't
  • 16:32 - 16:33
    and then I can write the proof
  • 16:33 - 16:35
    but that's my personal flow
  • 16:36 - 16:39
    I work from specific to general
  • 16:39 - 16:40
    this kind of inductive style
  • 16:40 - 16:43
    and I understand not everybody likes that
  • 16:43 - 16:45
    what I think is interesting though
  • 16:45 - 16:48
    even if I've been in that flow too
  • 16:48 - 16:51
    I had been in flow where TDD was working our well for me
  • 16:51 - 16:54
    it was ??? I should describe ???
  • 16:54 - 16:55
    it was very clear input
  • 16:55 - 16:57
    and was very clear desired output
  • 16:57 - 17:00
    and there were not a lot of contacts??
  • 17:00 - 17:02
    and there was not a lot of environment
  • 17:02 - 17:04
    to operate it
  • 17:04 - 17:05
    it was very pure
  • 17:05 - 17:08
    and for that
  • 17:08 - 17:12
    that would probably one case where I do actually like that flow
  • 17:12 - 17:16
    what I find is a lot of my work is not like that
  • 17:16 - 17:21
    right? sort of fundamentally maybe not like that
  • 17:21 - 17:26
    and then the problem comes in what am I willing to sacrifice to get that
  • 17:26 - 17:29
    you can reduce any type of work
  • 17:29 - 17:32
    certainly in the web space ???if you doing to that flow
  • 17:32 - 17:35
    if you just, that's where the whole mocking thing comes in, right?
  • 17:35 - 17:39
    if you just find a way and work hard enough
  • 17:39 - 17:42
    you can remove all the sort of dependencies
  • 17:42 - 17:46
    all the environment and reduce it to just one piece of input and one piece of output
  • 17:46 - 17:53
    is the flow important enough that you want to do that as general case?
  • 17:53 - 17:58
    how much you willing to sacrifice to be in that flow more ???you work
  • 17:58 - 18:01
    for me the answer has been
  • 18:01 - 18:03
    "I'm not willing to sacrifice that much."
  • 18:03 - 18:05
    when the flow is natural
  • 18:05 - 18:08
    when the work is sort of almost algorithmic nature
  • 18:08 - 18:11
    separated from all this context
  • 18:11 - 18:14
    alright. great. let's switch into that mode
  • 18:14 - 18:19
    but forcing all sort of other kinds of program work into this mode
  • 18:19 - 18:23
    just such that we can't feel the TDD loop?
  • 18:23 - 18:26
    that's where really see that we're going off track
  • 18:26 - 18:28
    and just coming up with some
  • 18:28 - 18:33
    in my opinion nasty hats we're starting really bad trade offs
  • 18:33 - 18:38
    for other aspects of the design of the code ????
  • 18:38 - 18:41
    so I'm curious for both of you guys
  • 18:41 - 18:45
    how much you guys willing to sacrifice to get to that TDD flow?
  • 18:45 - 18:48
    are you willing to use heavy amount of mocking
  • 18:48 - 18:51
    do you find that generally you can get there
  • 18:52 - 18:55
    in, say, MVC style programming?
  • 18:55 - 18:57
    or where the boundaries for you guys.
  • 18:57 - 19:03
    Martin is waiting for me talk
  • 19:03 - 19:05
    so I guess I'm talking.
  • 19:05 - 19:07
    so as I see I do this all the time
  • 19:07 - 19:10
    it's a question of trade off
  • 19:10 - 19:13
    and my students see me do that at thousands times
  • 19:13 - 19:16
    so for me TDD is question of trade offs
  • 19:16 - 19:21
    and I think, David you pointed out an important part of trade off which is
  • 19:21 - 19:29
    to make a design intermediate results testable comes with a cost
  • 19:29 - 19:32
    it comes with a benefit too
  • 19:32 - 19:37
    and you gotta figure out whether the costs outweigh the benefits
  • 19:37 - 19:43
    sometimes that's a question of understanding how to design things well
  • 19:43 - 19:46
    so if I'm building a compiler
  • 19:46 - 19:51
    and I think well the only kind of test I can have are end to end tests
  • 19:51 - 19:56
    and then I start to build more and more cases of what the input looks like
  • 19:56 - 20:00
    and I realize, "oh, I have this intermediate representation of parse tree"
  • 20:00 - 20:03
    then now I can test parsing
  • 20:03 - 20:05
    now I have this two orthogonal dimensions
  • 20:05 - 20:09
    I have parsing and then given a parse tree
  • 20:09 - 20:10
    does it compute the right results?
  • 20:10 - 20:15
    and then I can do more testing at a finer grain
  • 20:15 - 20:19
    but it was a design insight that created that moment
  • 20:20 - 20:26
    and compilers have settled on that as being a reasonable trade off
  • 20:26 - 20:29
    "ok, it's worth having this intermediate representation"
  • 20:29 - 20:34
    "so that we can have testability and bunch of other stuffs comes along with it."
  • 20:34 - 20:38
    so I'm not willing to say
  • 20:38 - 20:45
    ok, there's some fixed boundaries and I don't wanna twist design just to make things testable
  • 20:45 - 20:49
    because I'm just missing some design idea
  • 20:49 - 20:51
    if I had better idea for the design
  • 20:51 - 20:53
    then I could have both ways
  • 20:53 - 21:00
    I could have something that was more static more flexible design and it was more testable at the same time.
  • 21:00 - 21:02
    but if I don't have that today
  • 21:02 - 21:05
    your point is exactly right
  • 21:05 - 21:06
    then what do you do?
  • 21:06 - 21:10
    do you mock absolutely everything?
  • 21:10 - 21:13
    my personal practice is I mock almost nothing
  • 21:13 - 21:17
    if I can't figure out how test efficiently with the real stuff
  • 21:17 - 21:22
    I find another way of creating feed back look for myself
  • 21:22 - 21:23
    I have to have feed back loop
  • 21:23 - 21:26
    and a feed back loop has to be repeatable
  • 21:26 - 21:35
    but like I just don't go very far down the mock path
  • 21:35 - 21:42
    look at code where you have mocks returning mocks returning mocks
  • 21:42 - 21:44
    and my experience is
  • 21:45 - 21:49
    if i use TDD I can refactor stuff
  • 21:49 - 21:50
    and then I heard this stories
  • 21:50 - 21:55
    People say, "I use TDD and now I can't refactor anything"
  • 21:55 - 21:56
    I couldn't understand that
  • 21:56 - 21:58
    and then I started to looking at their tests
  • 21:58 - 22:02
    well. if you have mocks returning mocks returning mocks
  • 22:03 - 22:08
    your test is completely coupled to the implementation. not the interface
  • 22:08 - 22:10
    but the exact implementation of some object
  • 22:10 - 22:12
    you know three streets away
  • 22:12 - 22:15
    of course you can't change anything without breaking the tests
  • 22:15 - 22:19
    so that for me is too higher price to pay
  • 22:19 - 22:21
    that's not a trad off I'm willing to make
  • 22:21 - 22:25
    just to get piecemeal development
  • 22:25 - 22:29
    And this is, I think, at the heart of much of this
  • 22:29 - 22:32
    is confusion of terminology
  • 22:32 - 22:35
    and what these different things are
  • 22:35 - 22:41
    when I read David's initial blog post
  • 22:41 - 22:44
    cause I didn't see his talk until last night
  • 22:44 - 22:47
    one of things that came through very clearly
  • 22:47 - 22:50
    was his criticism of
  • 22:50 - 22:53
    David, your criticism of TDD
  • 22:53 - 22:57
    and sort of design damage that comes through it
  • 22:57 - 23:02
    had in itself very much tide in a notion
  • 23:02 - 23:05
    with the strong desire for isolation of mocking
  • 23:05 - 23:12
    and there, very important point that
  • 23:12 - 23:13
    there is nothing sort of
  • 23:13 - 23:17
    with in the idea of how you do either TDD or unit testing
  • 23:17 - 23:20
    that says you have to have that kind of isolation
  • 23:20 - 23:23
    some people are very much in favor of it
  • 23:23 - 23:24
    others are not
  • 23:24 - 23:27
    and I remember in the early days of extreme programming
  • 23:27 - 23:28
    unit testing, people would criticize us
  • 23:28 - 23:32
    that saying, "hey you're not isolating your units properly"
  • 23:32 - 23:33
    "that's not unit testing"
  • 23:33 - 23:39
    and we had this whole conversation with 24 different definitions of unit testing or whatever it was
  • 23:39 - 23:41
    ans said, "Well, our style of unit testing"
  • 23:41 - 23:43
    "we don't bubble about the isolation"
  • 23:43 - 23:46
    "and you know, it's working well for us, thank you very much"
  • 23:46 - 23:49
    so that's one thing
  • 23:49 - 23:53
    whether TDD in unit testing should be tide with isolation
  • 23:53 - 23:56
    and I look at it as different schools of thought
  • 23:56 - 23:57
    and I'm with Kent
  • 23:57 - 23:58
    I hardly ever use mocks
  • 23:58 - 24:01
    but I know good people who do
  • 24:01 - 24:04
    so I don't want to shoot everybody who uses mocks
  • 24:04 - 24:06
    maybe give it 10 more years
  • 24:06 - 24:08
    and then ????will ??? out or something
  • 24:08 - 24:10
    but we'll see
  • 24:10 - 24:18
    then there's another thing which is distinction between having what I call self testing code and TDD
  • 24:18 - 24:23
    to me, it's really important have self testing code
  • 24:23 - 24:29
    the ability to be able to run a single command have your whole system self test itself
  • 24:29 - 24:30
    in an acceptable amount of time
  • 24:30 - 24:33
    that is really powerful
  • 24:33 - 24:37
    because then if you can do that you can refactor with confidence
  • 24:37 - 24:40
    you've got a good chance of keeping your code base healthy
  • 24:40 - 24:45
    and that means you're able to be fast deliver new feature, etc
  • 24:45 - 24:47
    that is really powerful thing
  • 24:47 - 24:51
    and if I wanna get a ???high horse and say you must do something
  • 24:51 - 24:54
    I might be inclined to get that particular high horse.
  • 24:54 - 24:56
    but to me at least
  • 24:56 - 24:59
    TDD is one way to approach that
  • 24:59 - 25:02
    TDD is very particular technique
  • 25:02 - 25:06
    and if done well, one of benefit is that it gives you self testing code
  • 25:06 - 25:07
    give you all those benefits as well
  • 25:07 - 25:11
    but self testing code is for me perhaps the primary benefit
  • 25:11 - 25:14
    and the two get comflated
  • 25:14 - 25:20
    now fundamentally if somebody get self testing code by another root
  • 25:20 - 25:21
    such as when we started
  • 25:21 - 25:26
    we're delivering the code and the test together at the end of iteration
  • 25:26 - 25:29
    and you've got that self testing confidence
  • 25:29 - 25:31
    then I'm actually pretty happy
  • 25:31 - 25:35
    I'm not gonna kind of feel upset that somebody got that by another root
  • 25:35 - 25:38
    and I share with David and Kent
  • 25:38 - 25:41
    there're problems where TDD doesn't work terribly well
  • 25:41 - 25:44
    sadly most of programming I do these days
  • 25:44 - 25:45
    is not conducive to TDD
  • 25:45 - 25:46
    and I miss it
  • 25:46 - 25:49
    because actually I really like the TDD flow
  • 25:49 - 25:50
    that really works for me
  • 25:50 - 25:51
    just as it works for Kent
  • 25:51 - 25:57
    but fundamentally we have to separate TDD from self testing code
  • 25:57 - 25:58
    on realize they have different benefit
  • 25:59 - 26:00
    so often get conflated together
  • 26:00 - 26:04
    and we have to separate the idea of fully isolated unit testing
  • 26:05 - 26:07
    from not isolated unit testing
  • 26:07 - 26:10
    and realize that people have different preferences around those
  • 26:10 - 26:13
    and that's where I see
  • 26:13 - 26:18
    that was what much of my reaction was against, right?
  • 26:18 - 26:22
    that we had his prevailing definition of TDD
  • 26:22 - 26:25
    as not from you guys, from Kent
  • 26:25 - 26:30
    but from the people currently speaking in the program environment that I found was
  • 26:30 - 26:32
    A) very mock heavy
  • 26:32 - 26:39
    B) was very moralistic about the specific technique to get to the place we all want to get to
  • 26:40 - 26:43
    we all want to get to feel confident about making changes to the code
  • 26:43 - 26:46
    having self-test system that can run as a command and all these things
  • 26:46 - 26:50
    but you couldn't be part of that vote???
  • 26:50 - 26:53
    unless you also signed up for the TDD road to get there
  • 26:53 - 26:58
    and that's where I found it really frustrating
  • 26:58 - 27:02
    that we could have talked about whether we were being professionls or not
  • 27:03 - 27:04
    and that went through
  • 27:04 - 27:06
    well, you're writing test first
  • 27:06 - 27:07
    or you're writing them second
  • 27:07 - 27:11
    and related to that the whole TDD notion was propped up as
  • 27:11 - 27:14
    oh, well that self testing code you get
  • 27:14 - 27:15
    that's just a bi-product
  • 27:15 - 27:23
    that's a side benefit that some leftovers from driving your design through the tests, right?
  • 27:23 - 27:28
    that a lot of people really ??? onto this idea that TDD was not about self testing code
  • 27:28 - 27:31
    that was just a nice to have
  • 27:31 - 27:34
    but the key benefit was
  • 27:34 - 27:38
    the notion that you could only improve your design by making more testable
  • 27:38 - 27:39
    those two things equated
  • 27:39 - 27:44
    that easier to unit system was better designed system
  • 27:44 - 27:50
    that's the main heart of the fallacy and I want to take a real big swing at
  • 27:50 - 27:54
    because I started seeing a whole lot of code with this was not true at all
  • 27:54 - 27:55
    the code was not better
  • 27:55 - 27:57
    was not better design
  • 27:57 - 27:58
    just because it was more testable
  • 27:58 - 28:00
    it was full of these
  • 28:00 - 28:02
    mock that you guys talk about????
  • 28:02 - 28:09
    because we're trying to apply the unit test paradigm to areas of code that really didn't fit it very well
  • 28:09 - 28:15
    and we were discarding all sorts of really useful techniques, really useful patterns like Active Record
  • 28:15 - 28:16
    because it didn't fit
  • 28:16 - 28:21
    this notion of unit tests that had to run in 300 milliseconds
  • 28:21 - 28:22
    couldn't talk to the database
  • 28:22 - 28:24
    ??? wasn't isolated, right?
  • 28:24 - 28:27
    so we had to throw out all these productive work
  • 28:27 - 28:33
    just so that we put ??? about alter of Test Driven Design
  • 28:33 - 28:37
    and that every aspect or our system could be unit tested in isolation
  • 28:37 - 28:41
    that's where I think we needed reboot
  • 28:41 - 28:44
    and I think we still need to reboot
  • 28:44 - 28:45
    we haven't rebooted enough
  • 28:45 - 28:47
    like these thing to still intermingled
  • 28:47 - 28:52
    and while I think we're all very much in the same page
  • 28:52 - 28:54
    and trying to tease these things apart
  • 28:54 - 28:57
    most people throwing all into one big pot
  • 28:57 - 28:59
    they're calling that pot, TDD
  • 28:59 - 29:01
    and TDD means self tested code
  • 29:01 - 29:03
    and it means red green refactor
  • 29:03 - 29:06
    and it means mocks because you have to unit test everything
  • 29:06 - 29:10
    and it means this big ball of shit in some ways
  • 29:10 - 29:12
    because that's what comes out of it
  • 29:12 - 29:14
    the dish in the end it's just not tasty
  • 29:15 - 29:16
    the code is not great
  • 29:16 - 29:22
    there're other more important sacred principles than it's just testable
  • 29:22 - 29:24
    as in if the system clear and understandable
  • 29:24 - 29:26
    and all the other aspects of it
  • 29:26 - 29:29
    so that's where my frustration really is
  • 29:29 - 29:32
    so I get to play time cut now
  • 29:32 - 29:33
    we said we'd do 30 minutes
  • 29:33 - 29:35
    30 minutes has come up
  • 29:35 - 29:38
    and it seems that we'll do another one of this hang out
  • 29:38 - 29:41
    sometime in the future we haven't decided yet
  • 29:41 - 29:45
    but I think one way we can immediately begin is to explore this question
  • 29:45 - 29:50
    in what ways can a desire to TDD damage an architecture
  • 29:50 - 29:53
    and is it damage, right?
  • 29:53 - 29:58
    some people say the hexagonal rails stuff is much better that crap DHH is imposing on us
  • 29:58 - 30:00
    is that the case?
  • 30:00 - 30:01
    how do we evaluate it?
  • 30:01 - 30:04
    those sound like good questions to tacklle in the text episode
  • 30:04 - 30:08
    alright, thanks a lot
  • 30:11 - 30:16
    we'll set up a new date and shoot out another link
  • 30:16 - 30:17
    that's great
  • 30:18 - 30:20
    bye, bye
Title:
Is TDD dead?
Description:

more » « less
Video Language:
English, British
Duration:
30:26

English, British subtitles

Incomplete

Revisions