Live data from Hacker News

Ask HN: Should you TDD a MVP?

news.ycombinator.com

11–20 of 38 posts

Re: Ask HN: Should you TDD a MVP?

#11
post #7
post #5

Earlier quoted context omitted.

Okay now the less sarcastic- but equally harsh answer. If you think test driven development is not good you should not use it. If you think test driven development is good and you don't use it on your minimally viable product: then you are signaling that even you don't find the product interesting enough to even automatically exercise.

I disagree. I like TDD, but if you're quickly building a MVP that has beforehand been decided(1) to be thrown away once you've gotten funding, just hack it like you've never hacked something before. You're aiming to prove a concept, to visually display your idea. (1 - do make sure the non-technical people in the group really really really understand this)

Interesting. I still come out on the other side. If the product isn't being used much and might be the basis of pivot/re-factor, then tests become even more valuable. Better to catch the bug in a test than in your first demo.

Re: Ask HN: Should you TDD a MVP?

#12
This is a really good and interesting question, and it's one I've been struggling with myself.

The problem boils down to this: TDD makes your software more maintainable (if you do it well) and it lowers your cost of development. However, it also takes significant time and effort to figure out how to test-drive a technology for the first time. Everybody can TDD a Stack class; TDD'ing a database, or a web server, or JavaScript [0] is a lot harder.

So the answer seems simple: use TDD for the parts you already know how to TDD.

But it's not so simple! It's much harder to add tests to existing code than it is to TDD it from scratch. Sometimes, it's flat-out impossible. The expense is so high, there's a very good chance that you'll never get around to adding tests to the un-TDD'd code. It will hang around causing bugs, preventing refactoring, and sapping your agility forever, or until you rewrite... and a rewrite of any significance will halt your company in its tracks, so you won't do that.

So the reality is that, anything you don't TDD from the beginning, you'll probably never be able to TDD. Companies that go down this road find themselves doing a major rewrite several years down the road, and that's crippling [1].

There's another wrinkle on top of this: manually testing code and fixing bugs is expensive. Once your codebase gets above a certain size--about six developer-weeks of effort, let's say--the cost to manually test everything exceeds the cost to TDD it. (The six weeks number is a guess. Some people argue it's less than that.)

So the real answer is a bit more nuanced:

1. If your MVP is truly a throw-away product that will take less than six weeks to build and deploy and you'll never build on it after that, use TDD only where it makes you immediately faster.

2. If your MVP is the basis of a long-lived product, use TDD for the parts you know how to TDD and don't do the parts you don't know how to TDD. Be creative about cutting scope. If you must do something you don't know how to TDD, figure it out and TDD it.

3. It's okay to be a bit sloppy about TDD'ing the edges of your app that are easily rewritten or isolated in modules. But be very careful about the core of your system.

That's my opinion based on 13 years of doing this stuff, including building five successively-less-minimal MVPs over the last nine months for my JS screencast. The first three MVPs were zero coding, the fourth was a throw-away site, and the fifth was TDD'd with aggressive scope cutting to minimize the number of technologies that had to be TDD'd.

[0] Shameless plug: I have a screencast on TDD'ing JavaScript that I'll be opening up to the public, on a subscription basis, in a month or so. http://www.letscodejavascript.com .

[1] Rewrites are crippling: See Joel Spolsky's "Things You Should Never Do, Part I." http://www.joelonsoftware.com/articles/fog0000000069.html (There is no Part II, by the way.)

Re: Ask HN: Should you TDD a MVP?

#13
TDD is good for some things, terrible for others.

TDD's great when what you're working on is easy to test, like your data backend for your application.

It'll vary based on your product of course, but in my experience I've found the frontend to be the big time sink in development. Using TDD for contemporary frontend development is, in my opinion, a big time sink since the cost/benefit ratio of frontend testing today is way too high.

tl;dr use TDD for your backend (data model invariants) and hack your frontend as quickly as you can (on top of a decent frontend stack so you don't get that messy).

Re: Ask HN: Should you TDD a MVP?

#15
The key question here is, are you building a quick and dirty prototype, or are you building an MVP? MVP doesn't mean a garbage prototype. Depending on what you're doing, an MVP could still take significant time to build (and your MVP would take 1 month vs 3 months for the "full product.")

IMHO, if you're worried about supporting and maintaining your app, and concerned about your users not having a buggy experience, you should TDD it.

Re: Ask HN: Should you TDD a MVP?

#16
The question here is really "what's the test?" You have to reailze the MVP _is_ the test.

For a startup, customers are how you pass the test. Anything else is a red light. So in the most important way possible, as long as you have no customers, you have a test which is failing.

This is important because the maintainability you're looking for in a startup is your relationship with the customer. Manage that and the rest takes care of itself. If you are already in a business, yes, "maintainability" means writing code that will last. But if you've just got an idea or a dream, you've got nothing worth maintaining. Nor will you ever.

Put differently, your technical debt can never exceed the economic value of your code, which in a startup is extremely likely to be zero. (Different scenario entirely for project-based work for ongoing businesses, which is why TDD makes so much sense in that scenario)

Re: Ask HN: Should you TDD a MVP?

#17
post #11
post #7

Earlier quoted context omitted.

I disagree. I like TDD, but if you're quickly building a MVP that has beforehand been decided(1) to be thrown away once you've gotten funding, just hack it like you've never hacked something before. You're aiming to prove a concept, to visually display your idea. (1 - do make sure the non-technical people in the group really really really understand this)

Interesting. I still come out on the other side. If the product isn't being used much and might be the basis of pivot/re-factor, then tests become even more valuable. Better to catch the bug in a test than in your first demo.

I think it very much depends on what your MVP is, what your goal with it is.

My stance here is where the goal of the MVP is to get investment money. You're not showing your MVP to random users. You want to build something that "works" quickly, then get money to build it "properly". You have a good idea and you want to attack a certain market; but, you don't want to spend year(s) building a product and hope you can grow slowly. Your aim is to prove to investors that; you're a good team, you have a solid concept, with money you will gather a team and build this product.

In this case, I think you can(/should?!) skimp on the unit tests. The code will be thrown away after a few months of its inception.

There are of course many different MVP situations, this is just one small avenue.

Re: Ask HN: Should you TDD a MVP?

#18
Personally I wouldn't, but my opinion doesn't matter.

Does TDD help you? If so, use it! If not, don't! The whole point of an MVP is to ship something ASAP. Do whatever helps you do that.

Personally I've found TDD to be a tremendous waste of time for most things, but I know some people swear by it. It's your product. Git 'er done in whatever way you've learned to get things done.

Edited to add: People talk a lot about TDD leading to more maintainable, less coupled code. There's more than one way to skin a cat—not using TDD doesn't necessarily doom your codebase, and using TDD won't necessarily save it. Like I said, do whatever works for you.

Re: Ask HN: Should you TDD a MVP?

#19
What I'm writing below is meant in general, and not at the OP.

The purpose of an MVP is to find the minimum amount of value that a customer can't live without. An MVP is finding the 5 things you should have done in hindsight out of the 30 on your mind.

It sounds like you're focussing on yourself, and making your own life easier with TDD and not the customer. Wrong priority. You shouldn't expect your MVP to be here in 10 months.

Quit trying to prematurely optimize an empire that doesn't exist yet. Even if you write everything perfectly, you'll rewrite it from coding yourself into a corner and having to work out of it. You don't know what the problem-solution fit is, let alone whether theres a market of people willing to pay for it.

As history has shown, customers don't care what you code in, or how you code. It's more about building software that solves a pain and a problem, first, if you're serious about using the term "MVP". Sometimes folks keep doing what they've been doing and sprinkle some lean terms on it to make it sound like they're different.

TDD helps where there is complex business logic, not getting and setting basic information, which most MVP's do. If you have something that complex, it might not be an MVP.

Focus on the MVP, finding a product-market fit, and a problem-solution fit. Get out of the building and quit using methodologies as an excuse to analysis paralysis yourself.

Re: Ask HN: Should you TDD a MVP?

#20

This is a really good and interesting question, and it's one I've been struggling with myself. The problem boils down to this: TDD makes your software more maintainable (if you do it well) and it lowers your cost of development. However, it also takes significant time and effort to figure out how to test-drive a technology for the first time. Everybody can TDD a Stack class; TDD'ing a database, or a web server, or Ja…

I completely agree, and let me add to your point:

> manually testing code and fixing bugs is expensive

The codebase almost always starts small and simple, and the ratio of cost of development to the cost of testing will look misleadingly acceptable. Here's a made-up ratio:

2:1

As the codebase and complexity increase, keeping those ratios in the same proportion when manually testing is pretty much impossible, and the ratio may actually invert. Again, a made-up number:

1:2

If the business is relying on rolling out new features to continue to grow the business, this could become a big problem if revenue isn't growing at an even faster pace.

Post reply on HN