Live data from Hacker News

TDD: tastes better without the T?

coderoom.wordpress.com

31–40 of 60 posts

Re: TDD: tastes better without the T?

#32
post #7

Earlier quoted context omitted.

Perhaps that counts as an argument against accessor methods?

It's an argument against using accessors for the sake of using accessors. It's important when learning any technique (and this goes not just for programming) to understand why that technique makes sense in this situation, which means that you can evaluate later situations on a case-by-case basis and decide whether or not that technique fits. Too often people believe that a technique is good (Inheritance is good!) wit…

Thanks for interpreting my comment as more thoughtful than the blunt stab at OOP I wrote.

Re: TDD: tastes better without the T?

#33
post #26
post #22

Earlier quoted context omitted.

I think you would end up writing code in the REPL restricting what you would type because you know it'll become a test. Then you wouldn't using a REPL for what a REPL can offer, but writing test code. Unless it was really magical and would cover 100% of anything that someone could type in the REPL. If you were only using a subset of the REPL/languages features because you know your to-test-converter doesn't like some…

I'm confused. This would be a REPL enhancement , meaning it would be something you use as needed. Currenly, using the clojure REPL to test things comes with a twinge of guilt, as it is not being captured for regression tests. (and I am too lazy to write unit tests separately) This would make it so that using the REPL would cycle between two "styles", ad-hoc experimentation and then, when you've found some repeatable…

Yes, yes I am. :) The reason being, that first, it's annoying to have to set up the boilerplate for the file. Second, it's annoying to have to convert what I just exercised in the REPL into a test. (Setup, tear down, asserts.)

The reason TDD works and is fun is that you are using tests to learn and explore. It just so happens the artifact of that learning ends up living forever as a test. In a REPL, I'm doing that same learning and exploration already. The act of writing a test becomes as exciting as filing a TPS report.

Here's an example. I've just implemented a new function, and REPL'ed it to solidity. There were about 4-5 ad-hoc calls I made to the function to prove that it worked. I just finally got to the point where I can call it using my 4-5 different arguments, and it always outputs the right thing. Using readline, my arrow keys, and my enter key, I'm repeating the same series of steps over and over until the function works. We all do this. Win.

Now, I'm at a crossroads. Do I just start working on the next piece of the project? I know this piece works, I'm happy with it.

But wait! What if something changes. I need to write a test don't I. Sadness consumes me, since testing is slowing me down. I've already exercised the code, I already know it works, and I've already written the tests, albeit sloppily, in the REPL. Why do I have to switch gears now and start writing a file, running a test runner, and so on?

The truth is: I won't. I'll move onto the next thing, not breaking my flow and not doing something boring, something I already know the outcome of, instead of doing something fun: the next feature.

Maybe those who do switch off and go through the motions to write a test, repeating themselves, are more noble and careful in their programming. But I humbly suspect most of us are more lazy than noble :)

Re: TDD: tastes better without the T?

#34
I'm pretty sure I lost a $150k job opportunity for saying that TDD is a waste of time if your product hasn't been validated as a money maker. I don't regret saying it either.

Fast forward a month and I begin working on a pre-profit project that is so bloated with tests and unnecessary complexity that it took me a few days to really figure out what the hell was going on with the code. When I first started reviewing the code, I was thinking, "Wow, this guy's testing chops make me feel stupid.". Then, after really spending some time with the code, I just thought, "WTF!?".

It's clear he spent much more time writing tests than writing any features. On top of that, he had written 10 level deep abstractions for features that had features for their feature's features. In order to really understand the insanity of this you have to know that this site basically had 0 users and was going nowhere fast.

Then I was just pissed. Pissed at the thought of someone just getting paid to implement every feature under the sun without questioning if any of it was really necessary and with 0 user feedback. This is one of those instances where the developer makes thousands of dollars and the site and owner just lose thousands. This is totally unacceptable and irresponsible in my opinion.

The first thing I did was start removing features and didn't write one test for anything. I would have loved to just scrap the whole code base and start over, but there just wasn't time so I just had to rewrite as I went. You would think with all those fantastic tests, the code would be pretty solid, but I continually found incongruencies and errors. The database didn't even have foreign key constraints set up for any of the relationships. Why bother using a relational database?

I know that TDD is popular and I've seen job descriptions like "If you are just getting started with tests, don't even bother.", but I think there are a lot of developers wasting a huge amount of time and money writing tests for products that are destined to fail, partially because of all the time and money spent writing tests.

Re: TDD: tastes better without the T?

#35
post #25

What frequently floors me is the complexity of the test frameworks and utilities. Look at an average Rails shop, and their list of test helpers goes on forever. Stuff like mockups, creating test data and so on. I just hate learning frameworks. My dogma is fun driven development. If something is not fun, you are probably doing it wrong. Creating mock objects and ever more abstract test frameworks is not fun to me (ymm…

Not only that but they tend to be fragile and break when something in Rails or the other sub-frameworks they depend on changes. Somewhat ironic actually...

Re: TDD: tastes better without the T?

#36
post #2

This experience is emphasized even more if you work in a language with a REPL, like Clojure. The only value of tests, at that point, are to protect against regressions. The testing process with a REPL happens faster and more organically than writing unit tests, but it's less structured and harder to formalize. It's like comparing a structured debate to a conversation. What someone needs to do (and I'll do eventually)…

Yet another comment on HN that's significantly more insightful than the original article...

I think that speaks to the quality of the HN community.

Re: TDD: tastes better without the T?

#37
My use of tests is situational.

If I'm writing security-sensitive string parsing code that isn't going to change much, I'm going to write a thorough set of unit tests.

When I wrote database abstraction layer that ran on MySQL, PostgreSQL, Microsoft SQL Server and Oracle, I found that a good set of tests made the process of porting the system to a new database almost trivial.

Back when I was getting my PhD, I rewrote a simple-but-slow calculation to use a fast-but-complicated-as-hell algorithm, and I don't think it would have been possible (to get the right answer) if I hadn't used the simple code to create unit tests for the complicated code.

On the other hand, there are a lot of cases where I've written unit tests and they've become a liability over time; for instance, requirements would change, so I'd have to go back and maintain this collection of tests that, frankly, I didn't care about anymore.

Re: TDD: tastes better without the T?

#38
post #15

The biggest problem I have with TDD, or unit testing specifically, is the contortions (interfaces, mocking, delegating construction and configuration, configuration files, library dependencies, etc.) one has to go through to invert dependencies in statically typed languages. If only higher order module systems (think: parameterizing modules by their module dependencies, a bit like generic types are parameterized by t…

I'd be interested for you to expand on what you mean by "higher order module systems". Do you have any links?

I guess he meant systems like functors in ML/Ocaml.

Re: TDD: tastes better without the T?

#39
I can completely understand there being disagreement about how to test code, how much testing is enough, when to write test (test driven vs write tests later), etc.

But what boggles my mind is we've got people in this very thread who, if I'm interpreting their comments correctly, are arguing against doing any testing at all! WTF? How, in any non-trivial codebase, are you going to prevent regression?

Does anyone here have any experience in another engineering discipline (civil, mechanical, electrical engineering, etc). Isn't some sort of testing an accepted part of the process?

Maybe I'm wrong, but this seems like a huge sign of the immaturity of the discipline of software development.

Re: TDD: tastes better without the T?

#40
post #23
post #20

Earlier quoted context omitted.

I don't understand, why only corporate style commercial software (which I guess I don't know what it is too :p I thought the ones expected to already have this figured out are the awesome programmers, with more experience, the 10x more productive ones (which I do NOT include myself into). But why create this sub-group of "corporate style commercial"?

Well all I meant was the kind of dull, grey, software packages that corporations pay thousands for. As opposed to indie programmers or "cutting edge" commercial stuff - (i.e. Fogcreek, 37signals etc.) for whom things like TDD and agile tend to be big buzzwords. (oops I didnt fully answer your question: and the reason I singled it out is because all the TDD/agile stuff just passes that industry by - they've been using…

Fogcreek is actually fairly anti-TDD, unless that's just Joel speaking.
Post reply on HN