←back to thread

81 points whalesalad | 5 comments | | HN request time: 0.487s | source
1. cjs_ac ◴[] No.43647848[source]
I'm doing this with the SaaS I'm building (outside of my day job). My URL endpoint functions were directly executing SQL on the database until I decided that I couldn't go on like this, and only then did I write some classes to represent the business logic objects. It sounds ridiculous, but it gave me the flexibility to experiment with what those objects should do before imposing a formalism on them, and I found that very valuable.

At my day job, I'm expected to use TDD, and I don't like it. It's not that I don't like tests - I don't like writing them, but I like it when they're there, so I write them while feeling a bit grumpy. My problem with TDD is that I'm a big picture thinker, and I start from the inputs and work incrementally towards the outputs, without having a good outline of how I'm going to get there, so I can't write unit tests before writing any actual code, because I don't know what the units are going to be yet.

I also find my colleagues' code to be factored in a slightly unnatural way, because it reads like they've structured the code to match the tests, rather than written tests to test aspects of the code.

Maybe I should just be a hermit-programmer.

replies(4): >>43647883 #>>43648050 #>>43648127 #>>43651225 #
2. whalesalad ◴[] No.43647883[source]
imho TDD only works when you are augmenting an existing system. in the creative design phase, it's not as helpful. it can be no doubt, but it can also be a burden as you have pointed out. all things in moderation, as they say.
3. timcobb ◴[] No.43648050[source]
> until I decided that I couldn't go on like this, and only then did I write some classes to represent the business logic objects

this is just another form of TDD in my opinion. it's a bummer if your work literally makes you write tests first just to satisfy some theoretical checkmark.

> Maybe I should just be a hermit-programmer.

<3

4. BoiledCabbage ◴[] No.43648127[source]
> so I can't write unit tests before writing any actual code, because I don't know what the units are going to be yet.

How many tests do you write at your job (or are supposed to write) before you write the unit of code?

5. fire_lake ◴[] No.43651225[source]
TDD is opposed to suffering orientated programming IMO.

What pain does writing the tests first resolve? Tests should only be added when you are scared of making changes or want to support assumptions about how things work.