Ask HN: Do you write tests before the implementation?
241–250 of 329 posts
Re: Ask HN: Do you write tests before the implementation?
#242Earlier quoted context omitted.
At the risk of being serious for a moment, saying "please" and "thank you" are two of the lowest effort, highest reward, and plainly decent things you can do as a human.
Muh. It's OK to be one of those endless-pleasers-and-thankers, that's how you are... but stop being so fucking condescending about it! ...some of us "other kind" of people actually consider excessive politeness as offensive because it wastes time and pollutes conversations and after a certain we'll start actually being offensive with people like you, and you'll just stare amazed at how horrible people we can be! When…
Not everyone is relentlessly virtue signaling or karma whoring, whether in IRL or on HN.
Re: Ask HN: Do you write tests before the implementation?
#243The issue I find is that generally we aren't writing code we know the exact requirements for, so doing TDD means that not only are you refactoring your code as you understand the problem better, but you're also refactoring your tests, which increases the workload.
Maybe that's a sign that we need to spend a lot more time designing before implementing, but I've never worked anywhere that happens enough to use TDD as nicely as my experience with my Sinon clone.
Re: Ask HN: Do you write tests before the implementation?
#244Nope. I pretty much always find it to be counterproductive. Most of programming happens in the exploration phase. That's the real problem solving. You're just trying things and seeing if some api gives you what you want or works as you might expect. You have no idea which functions to call or what classes to use, etc. If you write the tests before you do the exploration, you're saying you know what you're going to fi…
> Be prepared to throw one away. You will anyway. Write a POC to learn then you can write tests first for production.
Re: Ask HN: Do you write tests before the implementation?
#245No. I have always felt that TDD gives a false feeling of safety and satisfaction, and that it is mostly a waste of time that could be better spend optimizing and refactoring. Testing simple code is simple and therefore pretty much useless. Testing complicated code is complicated and therefore more likely to fail by making to few or to many assumptions in the test, or completely screwing up the test code itself.
A couple of takeaways from your post: - knowing your code does what you expect is a _false_ sense of safety - if something is simple, it is useless - if something is complicated, it is useless
Re: Ask HN: Do you write tests before the implementation?
#246I do, TDD gives me such a sense of confidence that now that I'm used to, it's hard not to use. > Can you describe the practical benefit? Confidence that the code I'm writing does what it's supposed to. With the added benefit that I can easily add more tests if I'm not confident about some behaviors of the feature or easily add a test when a bug shows up. > Do you happen to rewrite the tests completely while doing the…
Isn't this just the benefit of tests, not necessarily TDD?
Re: Ask HN: Do you write tests before the implementation?
#247I have found that beating code is a great way to preserve my sleep and save the next person a headache.
Re: Ask HN: Do you write tests before the implementation?
#248No. And also 'do you write a test for everything?'. Also No. Tried it, ended up with too many tests. Quelle surprise. There is a time/money/cognitive cost to writing all those tests, they bring some benefit but usually not enough to cover the costs. I'm also going off the 'architect everything into a million pieces to make unit testing "easier"' approach. I heard someone saying that if you write a test and it never f…
Everyone's in the confessional booth here admitting dogmatic test-first-test-everything's not so hot in practice, which is nice, but how long until it becomes safe to answer with anything other than some variation of "love testing, it's always great, I love tests, more is better" when asked how you feel about testing in interviews?
I think maybe it's a thing where you're not supposed to say it, but once you do, it frees the interviewer up to admit it as well and they're happy.
Re: Ask HN: Do you write tests before the implementation?
#249No. Tests are like any other code. They incur technical debt and bugs at the same rate as other code. They also introduce friction to the development process. As your test suite grows, your dev process often begins to slow down unless you apply additional work to grease the wheels, which is yet another often unmeasured cost of testing in this fashion. So, in short, I view tests as a super useful, but over-applied too…
It's weird you bring up global warming when there is scientific consensus that it is not only happening but man made. Doesn't seem like a good analogy for something you want more data on.
Re: Ask HN: Do you write tests before the implementation?
#250Earlier quoted context omitted.
It's a weird quirk of the brain how easy it is to wait until the food hardens onto the cooking utensils before cleaning it (sometimes needing a hammer and chisel to remove it) rather than just rinsing it off immediately with water. Yet, despite knowing this, picking the former route every damn time anyways. If you're like this, try putting on some small bluetooth headphones. Now cleaning the dishes just becomes a way…
It's weird... I'm a real lazy person. I do the dishes immediately because of this reason, it's faster and easier. I absolutely hate doing crusty dishes. So, I'm just confused in general why people wait. Its straight up less effort to do it sooner than later.
Really, though?
It's simple procrastination which is always illogical.
Present-self buys temporary comfort at the expense of future-self.