Live data from Hacker News

Ask HN: Before I write a single line of code, I

news.ycombinator.com

21–27 of 27 posts

Re: Ask HN: Before I write a single line of code, I

#21

Earlier quoted context omitted.

Is that the obstacle to turning them into businesses? I think getting paying customers is the hard piece of the puzzle? The cashflow will help solve the spag-bowl problem. You can hire a chief refactoring officer :-)

There are a lot of obstacles to me turning my ideas/hobbies into businesses. Yes, getting paying customers is the hardest piece of the puzzle. On my last endeavor, I got way into the server-side weeds with profiles and accounts and billing. It was a neverending spiral because I had designed something far too complicated without a test suite; I decided it could never be completed. I think my biggest challenge was my c…

Why do you think you need TDD to write logical and tight code? It's one way, but there are less drastic ways to the same ends.

Re: Ask HN: Before I write a single line of code, I

#22

I'm tired of working for years on hobbies that ultimately get big and I think can turn into businesses only to find I have built this huge unmaintainable edifice of untested spaghetti that I have to shelve. So now, whether it's on the job or on my home project time, I get the git repo and build scripts squared away with some awesome testing framework that constantly watches the file system and rebuilds and running my…

TDD can give you higher quality code... which really only delays the inevitable refactor once the true specs and user needs are discovered. I usually write quick and dirty implementations (after doing some API design on paper) and see if it has sticking power... then write tests and often times rewrite the code entirely in TDD style once more is understood about the problem.

Re: Ask HN: Before I write a single line of code, I

#24

Earlier quoted context omitted.

There are a lot of obstacles to me turning my ideas/hobbies into businesses. Yes, getting paying customers is the hardest piece of the puzzle. On my last endeavor, I got way into the server-side weeds with profiles and accounts and billing. It was a neverending spiral because I had designed something far too complicated without a test suite; I decided it could never be completed. I think my biggest challenge was my c…

Why do you think you need TDD to write logical and tight code? It's one way, but there are less drastic ways to the same ends.

Just for me (YMMV) I find that when I write untested code, I make too many large cognitive leaps in my changes. My code looks good at the time and it usually looks well-factored, but entropy and shortcuts always seem to creep in there. Pile all those errors up over a 5 year timespan on code that slowly accretes since I'm maintaining it on my leisure time, and I always wind up with really untrustworthy code and occasional frustrating regressions when I make changes.

The test suite with good coverage gives me confidence that the code continues to work as I make changes (no regression bugs.) It's about having complete trust in my code, no second guessing, and no time ever wasted in a debugger chasing down issues.

And, I want to be able to cut a build at any time as long as all of my tests pass and feel confident I'm not shipping a broken build. I've never been able to do that on any project in the past, and I think it will be one mark of success on this new project. I've implemented a mini feature toggle system in my build scripts to make that possible.

Finally, I'm using Closure Compiler with full optimizations in my production build to do minification. Closure Compiler itself can (theoretically) break the build with its over-aggressive optimizations, so part of having a complete coverage test suite is being able to run the tests against the production build and catch any bad optimizations that CC makes. Because of my architectural choices, I REALLY need that test suite.

Do I need to write the tests before the production code (do full TDD) or can I write tests after? Well, I am the type of guy who won't write the tests after because I always want to move on to the next fun thing. I just force myself to do it, and take my medicine up front.

Re: Ask HN: Before I write a single line of code, I

#25
post #20
post #7

> Why? Or, is it just better to start coding and figure it all out on the fly? Yes it is. Write code towards the solution and see what it leads you. Then you might get into a "writers block" and can't decide whether data structure A or B is best. So you think about it some, decide which one you like and write more code. Then you might find out that you thought A was best but it turns out B was better. So you refactor…

In my experience it will lead to some half thought through design and a load of technical debt. "Weeks of coding can save you hours of planning".

In my experience, you would have gotten just as much technical debt and bad designs if you so had spent months of planning before typing the first character of your code.

Re: Ask HN: Before I write a single line of code, I

#26
post #25
post #20

Earlier quoted context omitted.

In my experience it will lead to some half thought through design and a load of technical debt. "Weeks of coding can save you hours of planning".

In my experience, you would have gotten just as much technical debt and bad designs if you so had spent months of planning before typing the first character of your code.

You must do some poor planning.

Re: Ask HN: Before I write a single line of code, I

#27

Earlier quoted context omitted.

Why do you think you need TDD to write logical and tight code? It's one way, but there are less drastic ways to the same ends.

Just for me (YMMV) I find that when I write untested code, I make too many large cognitive leaps in my changes. My code looks good at the time and it usually looks well-factored, but entropy and shortcuts always seem to creep in there. Pile all those errors up over a 5 year timespan on code that slowly accretes since I'm maintaining it on my leisure time, and I always wind up with really untrustworthy code and occasi…

There is a big difference between "untested code" and "tdd code"

There are two different ways to test code.

1) Do the TDD thing. Write 1 test. Code to pass. Repeat.

2) Write code that works. Iterate on it. Refactor, clean it up. Then write some tests that test the final product.

You can have tested code in both cases, but I claim the code from #2 will look cleaner than the code from #1.

Post reply on HN