Hacker News new | past | comments | ask | show | jobs | submit login

DHH largely creates a straw man: the fanatical, religious TDD devotee who blindly worships at the Altar of Unit Tests. For an enormous majority of the wider development community (who do no testing whatsoever outside of click-the-thing-and-see-if-it-works), TDD is an easy to understand, easy to get started way to improve the quality of your code. I haven't met any of these supposed religious zealots DHH is railing about, and I worked for an "Agile Consultancy".

Also, DHH argues against plenty of other best practices / design patterns and is considered incorrect in many of these cases (his "only use the Rails classes" objections to having a service layer most famously). It just so happens that when he bashes something that a lot of developers don't like to do already (write unit tests), the pitchforks rally behind him.

It's the same sort of thing when people post articles on HN bashing pair programming, or open workspaces. We get it. Some of you really don't like change, or anything "agile". Now please stop beating the dead horse already.




> DHH largely creates a straw man: the fanatical, religious TDD devotee who blindly worships at the Altar of Unit Tests.

That's not a straw man: That's real life. I've worked with people like this. They're fairly common in TDD shops. You even see them on Hacker News making spurious claims like how TDD would have prevented the <security hole> in <framework> (nevermind the fact that that <framework>'s dev teams is heavily invested in TDD)


I've seen code bases designed from the tests first and they were pleasant to work with.

I've worked jobs where it was my responsibility to salvage undocumented, untested legacy code and extend it with new features while keeping it running.

The truth is rarely in the extremes being characterized in these blog posts and discussion threads.

The only kind of test code I've seen that required far too many mocks and dependency injections tend to result from poor design choices and writing the tests after the functionality.

If TDD as a practice doesn't work for you, that's fine -- but I think it's disingenuous to offer no alternatives. Integration testing isn't an alternative; I use them in concert with a well tested code base. And I use whole-system tests too.

DHH works in a small corner of the field. TDD may not work well for Rails applications is all I've been able to glean from his posts. I think that's a battle for the Ruby/Rails community to have. It doesn't discredit TDD one bit.


> TDD may not work well for Rails applications is all I've been able to glean from his posts.

And even this is not the case - the Ruby/Rails community is heavily involved with TDD/testing frameworks/etc, because it is so easy to do and because unit tests can help bring some of the assurances you miss from static typing back into your systems.

The issue DHH has with TDD is, imo, all wrapped up in the issues he has with design patterns, service layers, etc. Doing TDD on a business ___domain object that subclasses ActiveRecord::Base forces you to mock/stub all sorts of DB calls (which is irritating), which in turn highlights the fact that, contrary to what DHH says, it's not always a very good idea to stick all of your business logic in the model layer.

DHH isn't having any of it, but by no means is he representative of the Ruby/Rails community here. (see: https://www.destroyallsoftware.com/screencasts/catalog/what-... for just one of many examples)


I really like Gary's videos. I wish I had stopped to meet him at Pycon this year (but I didn't know who he was until after his talk! Derp).

Thanks for pointing that out though; I didn't intend to assert

  dhh's opinion <=> rails community's opinion


Out of curiosity, where could/should business logic go in MVC-ish architectures?


Normally in the model; but often in Rails the "model" gets conflated with the "persistence layer." Many of us who develop in Rails feel that the persistence layer should have the single responsibility of persistence, and would like to use something like a DAO pattern there, keeping business objects / logic in pure Ruby classes.

Note that this is not necessary for small, simple Rails applications: by all means, if you're writing a blog app, stick everything in AR::Base and don't over-design. But once you start working in large-scale, non-trivial Rails apps, it becomes very painful to have to have all of your tests running against your database for example.

This is probably something of an idiosyncrasy of Rails, and may have little relevance to other frameworks / languages.


I've worked for one of the biggest agile consultancies around, and while most of the developers write unit tests, I never met anyone who started frothing at the mouth if we wrote code before tests. I just don't buy the pervasiveness of these TDD-devotees to the degree that justifies all of this backlash, DHH articles, HN comments, etc.


You probably got lucky.

But yeah, they exist


And I've worked in TDD shops for years and never seen the fanatical TDD devotee. I have seen lots of developers that will use any excuse they can find not to provide automated tests for their code.


I've met plenty of these devotees. I'm not sure that they practice what they preach, but I have felt the wrath of their judgment, to the point that I hate "admitting" that I don't believe in TDD. I, for one, am pleased that DHH has made my world a little brighter.


> I have felt the wrath of their judgment, to the point that I hate "admitting" that I don't believe in TDD

I'm not sure if you're exaggerating a little, but I think that having colleagues whose wrath makes you hesitant to express yourself is an entirely different issue from that of test-driven development or not. Development is a fairly easy field in which to demonstrate that you're at least as correct in your methodologies as another developer: just produce quality code. This feels (as these arguments very often feel to me) like a personality issue more than a methodological one.


I think you mis-characterize people's concern for pair programming and open workspaces. That alone makes me wonder how objectively you can look at this topic. TDD has become a foundational tenet of agile, so any criticisms of it naturally get seen as a criticism of agile (similar to open spaces and pair programming).

There's more than one way to skin a cat, and it isn't always fear of change that keeps people from changing.


> TDD has become a foundational tenet of agile

When I see "agile" and "tenet" in the same sentence, I think "government shop". An explicitly flexible premise (Agile) does not have "one true way" to do anything.


> TDD has become a foundational tenet of agile

Dear god, please take the straw man out back and shoot him already.

There really is no way to have an intellectually honest discussion about these subjects, is there?


"For an enormous majority of the wider development community" => noise generated does not equal the size of the community.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: