News for hackers. Stuff that matters.
Re:Kent Beck: “I get paid for code that works, not for tests... by kornakiewicz on Thursday December 08, 2016 @08:55AM (#13130248)
But we don't write tests to check if our code works. We write tests to be able to change it in the future with certain degree of confidence that we don't break anything and - if so - what exactly.

There are other techniques which can give similar confidence, but tests are the easiest one.

Re:Kent Beck: “I get paid for code that works, not for tests... by raldi on Thursday December 08, 2016 @10:18AM (#13130787)
I agree with your assessment that the primary reason we write unit tests is to be able to quickly make changes in the future without fear of breaking something: You do some extra work today so that you can save a tiny bit of work (and worry) tomorrow, and over time that accumulated future benefit outweighs the penalty paid today.

However, many in the industry forget that this is the underlying reasoning, as seen just two days ago here on this site. Read through the top-rated comments on this post: https://news.ycombinator.com/item?id=13119138

They describe an emergency situation where a single "3" needed to be changed to "4" ASAP or people would lose their jobs, and everyone's applauding the gatekeepers who insisted on significant refactoring and the creation of additional tests before the change could be approved.

I agree with those who say those improvements should maybe have been demanded immediately after the fire was out, but those who would have delayed the firefighting out of blind allegiance to the rules seemed, to me, to have forgotten that the rules are there to serve the programmers (particularly, their ability to quickly ship working code), and not the other way around.

A rule that's failing to do that should be changed or ignored.

Re:Kent Beck: “I get paid for code that works, not for tests... by didibus on Thursday December 08, 2016 @12:03PM (#13131835)
I wonder what would have happened if he had initially told the CEO it would take 6 days for the change?

"We can do that, but it will take us 6 days, otherwise we risk taking the plant down and aggravating the issue."

I wonder if the CEO would have just said ok thanks.

In my experience that's the case. The engineer in that link got himself in a bad spot, because he didn't know what was involved for the change when he communicated his estimate. And most of his back and forth that slowed him down would have been avoided had he known beforehand how to properly do it. Even with everyone's feedback it sounds like a 1 day code change. That seems to me like the reason the change was slow is more ramp up time for him working on a code base he doesn't normally work on.

Re:Kent Beck: “I get paid for code that works, not for tests... by raldi on Thursday December 08, 2016 @12:17PM (#13131981)
I agree that the best possible answer to management would have been, "It'll take six days by the book, or if you approve some emergency rulebreaking and the issuance of technical debt, I can have it done in an hour. And then it'll take six days to clean up."

Then the boss can make an informed decision.

Re:Kent Beck: “I get paid for code that works, not for tests... by beat on Thursday December 08, 2016 @01:40PM (#13132854)
Yes, this. Provide options to management, with risk analysis, so they can make a decision. Management's priorities are not always the same as development's priorities.

The important thing here is to provide the risk-assessed alternative in writing. This covers the asses of both sides! If something blows up and management was not warned about the possibility, they're well within their rights to rake the engineers over the coals for it. But if engineers warn management of the potential consequences and management chooses to take the risk, if it blows up, you have your CYA right there - they were warned in writing.

Re:Kent Beck: “I get paid for code that works, not for tests... by imagist on Thursday December 08, 2016 @03:09PM (#13133814)
This works if you trust your manager to take responsibility for the decision, which you often (usually?) can't.

If you can't trust your manager to take responsibility for the decision, then it's better to make a decision you're going to be held accountable for than to let your manager make the decision and then hold you accountable.

I've seen other engineers in the position where they give a risk analysis and warning in writing, and then shit hits the fan and they get fired. Maybe it doesn't happen immediately, maybe the reason they were fired isn't explicit, but the change in the manager's attitude toward the engineer traces back to when they did what the manager said.

There are also mangers who won't follow through on the tech debt part because they don't trust their engineers even if their engineers are trustworthy. When they discover that they can bypass testing by pulling the emergency lever, they'll start pulling it all the time because they see it as a way to get what those lazy engineers to do their jobs faster. And when tech debt catches up with you, bugs abound, and development slows to a crawl, the engineers get blamed.

Maybe you have a boss you can trust to take responsibility for their risky decisions. Maybe your boss trusts you when you say that paying down tech debt is necessary. But maybe your boss and their boss don't have the same relationship, and the shit rolls down hill.

Yes, I want to work in a trusting environment where my interests are aligned with doing what's best for my company, but an at-will employment capitalist economy doesn't always work that way. It's every man for himself at a fundamental level, and exceptions to that are too rare to make a blanket claim that people should just do what's best for their company.

Re:Kent Beck: “I get paid for code that works, not for tests... by beat on Thursday December 08, 2016 @04:06PM (#13134306)
If you can't trust your boss to not scapegoat you when you provide a risk analysis in writing, you need another job.
Re:Kent Beck: “I get paid for code that works, not for tests... by imagist on Thursday December 08, 2016 @05:42PM (#13134988)
Eh, it's not all that big of a problem of you know how to deal with it (protect your own interests, not the company's, by making conservative choices as I described above).

I work 35 hours a week, make $125k/year, have good benefits, like most of my coworkers, and am doing relatively interesting work for a company that isn't completely evil. Sure, my boss can scapegoat me if I let him make technical decisions, but I don't. That's a tradeoff I'm okay with. I'm always on the lookout for something better but I'm happy where I am.

And besides, most people who think their bosses won't scapegoat them if something goes wrong are naive. If it's your job or theirs and they have the power, you're screwed. It's better to avoid the risk and not put yourself in that situation.

To be clear, I'm not saying don't take risks. I'm saying wroth risks on your own behalf.

[dead]
Re:Kent Beck: “I get paid for code that works, not for tests... by imagist on Thursday December 08, 2016 @05:51PM (#13135056)
I'm not proposing you shouldn't work hard, and I don't work for a large enterprise. I'm unsure how you got that from what I said.
Re:Kent Beck: “I get paid for code that works, not for tests... by didibus on Friday December 09, 2016 @03:58PM (#13141788)
I agree with you. I think most often then not, you need to withhold the inferior alternative, or be very careful in how you presented it. If you downplay the risks, or you don't emphasize them enough one way or another, it will still end up being your fault, even in writing.

Trade offs that are business related can be delegated and should be delegated to the business to make. But saying something like: "if we do A, it could make us vulnerable to X,Y,Z technical problems, but would allow you to have what your business needs 7 days early" can be dangerous, because it assumes the business stakeholders truly understands the dangers of technical issues X,Y and Z, which they almost always do not.

As an engineer, you should advise the business towards the proper way to do things, and you are responsible to make sure your advice is clear and loud. It is sometimes appropriate to suggest the less ideal scenario, but if you do, be ready to assume full responsibility and ownership on it.

You should never have an advice that goes like: "Yes we can do it, but it'll cause other problems." and expect for these other problems to not be your responsibility to fix and mitigate as they appear. The implicit of all your suggestions is always: "I can make this work." So better be sure whatever you suggest you can actually have it work.

Re:Kent Beck: “I get paid for code that works, not for tests... by pmoriarty on Thursday December 08, 2016 @07:37PM (#13135709)
"Yes, I want to work in a trusting environment where my interests are aligned with doing what's best for my company, but an at-will employment capitalist economy doesn't always work that way."

What economy does work that way?

Re:Kent Beck: “I get paid for code that works, not for tests... by imagist on Friday December 09, 2016 @07:25AM (#13138331)
Employee-owned cooperatives sidestep this issue pretty well by empowering workers. I don't know of any entire economies, though.
Re:Kent Beck: “I get paid for code that works, not for tests... by hinkley on Thursday December 08, 2016 @04:54PM (#13134637)
It's important not to understate the fact that both options are a false choice. you can have it the right way Plan A, or the right way Plan B. There was no offer of a Plan C where we hack stuff and then just hope for the best.

Plan C is what the Strategy guys always want to go for, because they can't recognize when the repucussions happen. They just tell themselves it's those good for nothing engineers screwing up again.

But too often there's been one guy ithe engineering group who values accolades over stability and will offer to be a hero, only to wander off without finishing anything. Later in life I've realized I should have suffered through more of the issues at companies where the team at least had solidarity. I knew I wanted that in a team, but didn't know that I needed it.

Re:Kent Beck: “I get paid for code that works, not for tests... by beat on Thursday December 08, 2016 @05:46PM (#13135021)
That's why you don't offer a Plan C. There's a fast-but-dangerous Plan B, with a risk analysis. You've warned them what can happen, in writing. Now, if something goes wrong that you didn't warn about, there could be other repercussions, but that's still better than not warning them at all, which easily makes you the "But no one told me this could happen!" scapegoat.

Plan C doesn't differ from Plan B in terms of technical approach. It differs in terms of the consequences of failure - not the technical consequences, but the political consequences.

My first really interesting project that led me down the sort of DevOps/Agile trail was in the mid-1990s, when I helped write a risk management and contingency planning process for the mid-sized company where I worked. One of the features of the process was that management could not reject a risk analysis on any grounds except incompleteness. They couldn't say "I don't want that written down!" They had to sign off on it, in writing.

This turned out to be very popular with both teams and management. Teams felt they were finally getting the opportunity to cover their asses, and management finally felt like they were getting straight answers from the teams about actual risks. In the earlier lack of process, teams were at least passively discouraged from honest, written risk analysis, as naysayers who were resisting business opportunities. Worse, if a warning was given and then the problem happened, the people who warned were blamed for not preventing the problem!

When we beta-tested the analysis process, the first project that tried it actually turned down business because it was too risky. That had never happened before. We probably saved the company many millions.

Re:Kent Beck: “I get paid for code that works, not for tests... by edoceo on Thursday December 08, 2016 @03:21PM (#13133917)
Manager agrees, rulebreaking then fix later.

Later...never arrived for tomorrow is another Very Important Thing that must be done now!

Somehow management continues to forget the critical resource: time to do things right

Re:Kent Beck: “I get paid for code that works, not for tests... by marcelvaldez on Thursday December 08, 2016 @06:47PM (#13135440)
Yeah, but the problem is that managers are not engineers, they want "results" and do not have sufficient software engineering knowledge to be aware of the effects of making this type of decisions over and over again.

Eventually the software engineering department has a code base that is riddled with tech debt, to a point where changing a 3 into a 4 ACTUALLY takes 6 days.

Then management asks "WTF? What did you do? Why does it take 6 days to turn a 3 into a 4?", next comes frustration and SWEs leave the company.

I've seen this happen at 3 different companies in 3 different industries, a huge company (hundreds of devs), a medium company (50 devs), and a small company (2 devs) [1].

Every time it happened, it was because a SWE team was constantly delivering under pressure by management that disregarded the cost of writing code "that works" without ever addressing tech-debt, no matter how much the SWEs warned management.

[1] To be fair the small company only fell into that anti-pattern because neither the engineers nor the managers knew any better.

Re:Kent Beck: “I get paid for code that works, not for tests... by raldi on Thursday December 08, 2016 @07:00PM (#13135527)
Perhaps the reason you've seen this phenomenon everywhere is that the companies that don't do it tend to fail, whereas the companies that do tend to succeed and grow and hire people like you.
Re:Kent Beck: “I get paid for code that works, not for tests... by taneq on Thursday December 08, 2016 @07:23PM (#13135630)
This was one of the most important lessons I learned at my first job out of university. Beautiful, well structured, clear, simple code is nice, but the customer doesn't give a shit about it. All the customer cares about is that your product solves their problem.

By all means, if you have additional resources, invest them in refactoring and improvements and additional testing and continuous integration and all those things that make our days enjoyable and our product quality high. But your first priority has to be making sure that your product solves your customer's problem.

Re:Kent Beck: “I get paid for code that works, not for tests... by dustinmoris on Friday December 09, 2016 @05:25AM (#13137874)
I disagree with this. Management doesn't need to micro-manage everything, that's certainly not their job role. This was a simple change in an internal system. Yes, maybe this minor super isolated change could have broken something in some parallel world, but the stuff it would have broken is not an airplane computer or a heart machine. Bloody hell, sometimes it is important to put things into context. Engineers get paid a hell lot of money and you would expect that someone with that qualification and level of experience would be capable to make smart decisions independently without being micro-managed by a manager all the time. After all the engineer is the real expert of his/her code and can make a much better assessment of the impact of the change than the manager, so freaking do it! That's what you get paid for! Seriously, there was no excuse for this to take 6 days.
Re:Kent Beck: “I get paid for code that works, not for tests... by mcv on Monday December 12, 2016 @06:42AM (#13157369)
Increasing the backlog by a month is not so urgent that 6 days is a problem. It's useful to have a process in place for more urgent hotfixes in production, but I don't see why that would be needed for this particular case. And rushing changes for a mission critical system can be very dangerous.
Re:Kent Beck: “I get paid for code that works, not for tests... by raldi on Monday December 12, 2016 @10:08AM (#13158517)
Re:Kent Beck: “I get paid for code that works, not for tests... by mcv on Monday December 12, 2016 @10:22AM (#13158629)
More accurately: by the parent of that comment.
Re:Kent Beck: “I get paid for code that works, not for tests... by Too on Sunday December 11, 2016 @03:01AM (#13150090)
This handshake adds yet another day to the process though.
Re:Kent Beck: “I get paid for code that works, not for tests... by snovv_crash on Thursday December 08, 2016 @03:18PM (#13133893)
If you read closely, it was only 6 days because the CEO did some rulebreaking at the end. I imagine it would have been several weeks otherwise.

At some point organisations forget that the process is there to serve us, and not us to serve the process. Moving variables to parameter files, renaming legacy variables, these all seem like much more risky things than simply changing the value of the variable.

Re:Kent Beck: “I get paid for code that works, not for tests... by rplst8 on Thursday December 08, 2016 @01:32PM (#13132758)
> I agree with those who say those improvements should maybe have been demanded immediately after the fire was out, but those who would have delayed the firefighting out of blind allegiance to the rules seemed, to me, to have forgotten that the rules are there to serve the programmers (particularly, their ability to quickly ship working code), and not the other way around.

I think it depends on the type of product you are working on. Certain domains require very strict adherence to policy - for very good reason. Just because your shiny new aircraft's deadline is tomorrow, doesn't mean you can skimp on the required testing.

Re:Kent Beck: “I get paid for code that works, not for tests... by bluesign on Thursday December 08, 2016 @10:48AM (#13130997)
I think the linked thread is good example, changing 3 to 4 can seems minor, but i think even with rules in place, it is not a burning 'fire', it should be easily acceptable to run this with rules enforced in a day or two. Letting people to override rules is more damage in long run for sure. Maybe they would override next time when they shouldnt
Re:Kent Beck: “I get paid for code that works, not for tests... by raldi on Thursday December 08, 2016 @10:58AM (#13131116)
Sorry, but you don't get to make that call; it's the CEO's job, and the CEO said it needed to be done immediately, not in "a day or two".
Re:Kent Beck: “I get paid for code that works, not for tests... by didibus on Thursday December 08, 2016 @11:55AM (#13131722)
I wholeheartedly disagree. In fact, I believe that's the difference between an engineer and a programmer.

If you are hired as a programmer, then yes, just do whatever we ask of you.

But if you are hired as an engineer, everything the business asks of you comes with an implicit: "and make sure it's done in a proper way that won't break anything, or slow us down, or cost us too much, or limit our ability to gain a competitive edge."

You don't just change a 3 to a 4 because the CEO wants you to. You have to make sure the change doesn't come with unforseen impact that would put the company at risk, and you have to make the change in a similar way. That's what the CEO expects also. If you did the change, and it had caused impact to the business, that you had not pointed out, and for which the business believe is more harmful then having waited a few more days, you and only you are to blame, and you will be. You can't say, but CEO told me, you're the engineer, you're the person they hired to know this stuff and prevent these issues from happening, not the CEO.

Re:Kent Beck: “I get paid for code that works, not for tests... by nostrademons on Thursday December 08, 2016 @01:28PM (#13132711)
The point is that decisions should be made by the people who have the proper information to make them.

If the CEO lacks the understanding of the technical consequences of a change that may blow up the company, the engineer should make the decision. If the engineer lacks understanding of the business consequences of not making the change - like losing an important client, or suffering a wave of negative PR, or facing a lawsuit - then the CEO should make it. Ideally, both sides should be communicating these consequences so that both of them have all the relevant information and would ideally make the same decision. Then the decisions can get made at the lowest level that has all this information, and the CEO doesn't have to get involved.

In practice, there are many cases where the CEO can't communicate all of the relevant business realities, eg. if you're facing a lawsuit if you don't make a change, it's often better not to worry the rest of the staff or make them subject to depositions, and simply to ensure that the change gets made. That's why the CEO is the decider by default in organizations, and also why it's usually expected that employees will obey a direct order from the CEO or be fired.

Re:Kent Beck: “I get paid for code that works, not for tests... by raldi on Thursday December 08, 2016 @12:22PM (#13132039)
I'm not sure we're actually in disagreement. If Captain Kirk tells Scotty, "We need warp 9 in five minutes or we lose the ship" and Scotty cuts corners that cause a decompression explosion that kills twenty redshirts, then yes, that would probably be an example of bad engineering management.

But if Scotty delivers on time at the cost of overloading an expensive piece of equipment that, after the battle is won, requires a week in drydock to replace, that's probably a successful execution of exactly the kind of call a senior engineering manager is expected to make.

Re:Kent Beck: “I get paid for code that works, not for tests... by mcv on Monday December 12, 2016 @10:33AM (#13158719)
If Scotty didn't confirm that it's important enough to risk serious damage, he didn't do his job. His job is not to blindly trust the captains omniscience, his job is to inform the captain of the technical consequences. If warp 9 in 15 minutes is preferable to taking damage, than that's the better option.

In the example with the line of code that took 6 days, there was no dramatic emergency in production that required cutting corners. If it had been an emergency, of course the code refactoring demanded in code review should have been postponed; those changes increased the impact of the change, and therefore the resting requirements.

And if it really is an emergence that requires people to drop what they're doing, then someone with sufficient authority should be directly involved in order to override all the usual procedures.

But you don't just drop all procedures just because somebody claims somebody said something. That would be dangerously irresponsible.

Re:Kent Beck: “I get paid for code that works, not for tests... by didibus on Friday December 09, 2016 @04:26PM (#13141990)
Could be we don't, most disagreement is miscommunication.

In your example, Scotty knew what he was doing though. He didn't say, wow, what Kirk wants me to do could kill twenty redshirts in the process, I'll just take the gamble since he seems to want me to. He knew exactly the impact, and made it knowing he would easily be able to contain it.

Which is often not the case in Software and in practice. You have to do something to know the impact, because most problem we solve is always new. Its not something we did many times before. If that variable was often changed, then it would be completely different, because he'd known, just like Scotty, that its something they can do. In that case you can make the choice to say, lets change it, and later handle the tech dept of the less maintainable code.

Also, in software, its almost never the case that people can't wait a few more days.

Re:Kent Beck: “I get paid for code that works, not for tests... by mjevans on Thursday December 08, 2016 @01:37PM (#13132814)
It always amazed me how little Star Trek used robots, even just remote arms, to do things. (Yeah, it's a side-effect of it being made for TV)
Re:Kent Beck: “I get paid for code that works, not for tests... by Natsu on Thursday December 08, 2016 @02:58PM (#13133705)
Trek wasn't made for logical consistency. They could duplicate Riker with a transporter accident, but they couldn't make another Data that way, they had an entire episode about deconstructing him, then another about him constructing a 'child' robot.
Re:Kent Beck: “I get paid for code that works, not for tests... by somecallitblues on Thursday December 08, 2016 @05:00PM (#13134679)
This seperation of programmers to mindless programmers and somehow superior engineers is bullshit. You have to follow the best practices in whatever you do.
Re:Kent Beck: “I get paid for code that works, not for tests... by mlashcorp on Thursday December 08, 2016 @05:29PM (#13134896)
Some people know how to program. Other people dedicated years to the study of computer architectures, first order logic, distributed systems, fault tolerant systems, etc ...

In my opinion, computer science and engineering is not about just making the code you're told, it's about questioning whether that code needs to be done in the first place, and if so, how.

Re:Kent Beck: “I get paid for code that works, not for tests... by tracker1 on Thursday December 08, 2016 @05:43PM (#13134995)
Most software development is not done, or meant to be done as an engineering discipline. It is far more often a craft. That said, it depends on the project, environment, company and legal requirements.
Re:Kent Beck: “I get paid for code that works, not for tests... by mlashcorp on Thursday December 08, 2016 @06:07PM (#13135167)
For that, hire a programmer. Need a dependable architecture for mission critical software? You get the point ...
Re:Kent Beck: “I get paid for code that works, not for tests... by tracker1 on Friday December 09, 2016 @02:43AM (#13137331)
Define mission critical? Can be down for a 15 minute update once a week? Most have transparent updates? Should be up most of the time? Must be up durring East coast business hours?

It still depends.

Re:Kent Beck: “I get paid for code that works, not for tests... by rplst8 on Thursday December 08, 2016 @01:34PM (#13132783)
> If you are hired as a programmer, then yes, just do whatever we ask of you. But if you are hired as an engineer, everything the business asks of you comes with an implicit: "and make sure it's done in a proper way that won't break anything, or slow us down, or cost us too much, or limit our ability to gain a competitive edge."

This is a distinction that is a very thin line and most people with "engineer" in their title would not sign up for.

Re:Kent Beck: “I get paid for code that works, not for tests... by Nomentatus on Thursday December 08, 2016 @01:53PM (#13132972)
True, most engineers, and others, will commit crimes including criminal negligence, when asked firmly enough by a powerful corporation that can fire them. See Flint, Michigan, the great robbery of 2008 etc, etc. But the idea of a profession is that you don't, that you have professional ethics.
Re:Kent Beck: “I get paid for code that works, not for tests... by rplst8 on Thursday December 08, 2016 @05:22PM (#13134846)
Yeah the term engineer is thrown around pretty casually in the software world. You can apprentice and take the PE (Professional Engineer) test, but it's often hard to find software engineers with their PE certificate. It's much more common in other fields like Mechanical, Electrical, and primarily Civil.

It all my years (15) of professional experience, I've only worked under one PE, an Electrical Engineer.

In some states you literally can not have "engineer" in your job title unless you have a PE certificate/accreditation/whatever.

Re:Kent Beck: “I get paid for code that works, not for tests... by taneq on Thursday December 08, 2016 @07:25PM (#13135642)
Exactly. As an engineer, no matter what your boss says, you are responsible for the consequences of your actions. If the CEO tells you to do something which you know is unsafe, you must decline (and explain why, preferably).
Re:Kent Beck: “I get paid for code that works, not for tests... by switchbak on Thursday December 08, 2016 @11:33AM (#13131482)
Having read that article, I do agree - but the requested change, while being "one line", could have unforeseen consequences that could also have a very negative effect on the business. I'm thinking that the CEO wouldn't take the blame for that though.

But if people's jobs were truly on the line, I'm inclined to agree with the "screw it, push it through" approach.

Re:Kent Beck: “I get paid for code that works, not for tests... by user5994461 on Thursday December 08, 2016 @11:58AM (#13131758)
Sorry, the CEO's job is not to talk about nitpicky technical details. He's got no voice in what a code or a test should be.
Re:Kent Beck: “I get paid for code that works, not for tests... by bluesign on Thursday December 08, 2016 @04:35PM (#13134522)
Ok this is the problem with story telling tbh:

David: It's for Philip. It we don't do this right away, we'll have to have a layoff.

and

Judy: OK, then I'll fill out that section myself and put this on the fast track. ----- 2 days later. ----- David: What's the status of 129281?

"It we don't do this right away, we'll have to have a layoff" and "2 days later", making an impression of this is an "a day or two" task, not a "fire/emergency"

I don't think if this change finished in 2 days anyone will be unhappy. But if you took this to production, and somehow failed, everyone would blame QA/testing

Re:Kent Beck: “I get paid for code that works, not for tests... by snovv_crash on Thursday December 08, 2016 @03:28PM (#13133967)
Those rules that were overridden were basically QA bikeshedding about variable names in something that has never changed before, and insisting on tacking on refactoring while trying to put out fires.

The engineer did their due diligence, wrote tests to make sure it had the desired behaviour, and got it done in minimal time. Clearing technical debt in old modules should be done, I agree, but not while trying to put out fires. It adds considerable risk to a change which should not have any impact except for the request.

Re:Kent Beck: “I get paid for code that works, not for tests... by ZeroFries on Thursday December 08, 2016 @11:36AM (#13131516)
The ideal solution is neither always enforce the rule nor always permit lapses. Are you saying you don't think human beings are capable of coming close to that ideal solution?
Re:Kent Beck: “I get paid for code that works, not for tests... by lotyrin on Thursday December 08, 2016 @11:44AM (#13131607)
In my experience, no, they cannot exercise judgment and an absolute system has to be in place.

In theory, could informed, intelligent, rational actors without ulterior motive do so, sure. I'd sleep on a couch and eat ramen for the chance to be part of such a team, but I haven't met them.

Re:Kent Beck: “I get paid for code that works, not for tests... by protomyth on Thursday December 08, 2016 @08:56PM (#13136070)
> everyone's applauding the gatekeepers who insisted on significant refactoring and the creation of additional tests before the change could be approved.

I certainly didn't applaud the gatekeeper because I believe they opened themselves up to a great risk. If you are doing an emergency patch to production you should minimize the amount of changes. All the refactoring of code was an unnecessary, reckless risk. The refactoring should move to the next scheduled release as the top priority since part of it is already in production.

Re:Kent Beck: “I get paid for code that works, not for tests... by jlarocco on Thursday December 08, 2016 @06:23PM (#13135282)
The scenario in the linked post was not a "fire", and it makes sense that it would require going through the regular process. If it were a fire then where was the CEO after step one? Why didn't he (or the 'operations manager') send out an email to everybody informing them to bypass the regular process?

A fire is something like, "the site is down for XX% of customers!" (for a large value of XX) or the "the software is routing product to the wrong place!" No doubt a real fire would have been handled differently.

Re:Kent Beck: “I get paid for code that works, not for tests... by wnevets on Thursday December 08, 2016 @10:39AM (#13130915)
Everything in moderation.
Re:Kent Beck: “I get paid for code that works, not for tests... by nurettin on Thursday December 08, 2016 @10:44AM (#13130962)
That's rather extreme.
Re:Kent Beck: “I get paid for code that works, not for tests... by codeduck on Thursday December 08, 2016 @10:42AM (#13130937)
including moderation.
Re:Kent Beck: “I get paid for code that works, not for tests... by matthewmorgan on Thursday December 08, 2016 @01:00PM (#13132436)
I prefer a slightly different translation of that Ancient Greek saying: nothing too much
Re:Kent Beck: “I get paid for code that works, not for tests... by 0xdeadbeefbabe on Thursday December 08, 2016 @02:41PM (#13133464)
For a moderate amount of everything.
Re:Kent Beck: “I get paid for code that works, not for tests... by st3v3r on Thursday December 08, 2016 @01:13PM (#13132564)
I think most people here have had the experience that the agreement will be made that the fixes will come "later". And then later never comes.
Re:Kent Beck: “I get paid for code that works, not for tests... by Alex3917 on Thursday December 08, 2016 @09:03AM (#13130282)
> But we don't write tests to check if our code works.

I write tests to check if my code works. And tests that document how the code is supposed to work currently are usually enough to prevent code from breaking in the future.

Anything related to privacy or security should be fully tested. But for the typical startup, I'd posit that beyond that test coverage should be more closely related to the number of users and level of usage rather than to the amount of code.

Re:Kent Beck: “I get paid for code that works, not for tests... by e40 on Thursday December 08, 2016 @10:24AM (#13130828)
The number of times my tests have 1) found bugs in my code, and 2) exposed problems with the API I was about to publish... uncountable.
Re:Kent Beck: “I get paid for code that works, not for tests... by mannykannot on Thursday December 08, 2016 @03:11PM (#13133832)
More generally, testing effort should be distributed according to a risk analysis. Even a one-off statistical report can have serious consequences if far-reaching decisions are made on its basis.
Re:Kent Beck: “I get paid for code that works, not for tests... by aequitas on Thursday December 08, 2016 @02:48PM (#13133566)
> And tests that document how the code is supposed to work...

For me the most important word here is 'supposed'.

All the time I read documentation describe how code works step by step (what each 'if' does, but spelled out more verbose). And test that only test that a function does by mocking out everything else.

But I don't care reading what code does. I can see that by looking at the code. I want to know what the developer intended/expected the code to do, so I can validate it against what the code actually does. Most of the time assumptions are made with those expectations. And with those expectations you have a much better idea why a trivial refactor of a piece of logic could unearth a massive 'undocumented feature'.

Re:Kent Beck: “I get paid for code that works, not for tests... by hannob on Thursday December 08, 2016 @10:32AM (#13130876)
> Anything related to privacy or security should be fully tested.

How often do you write code that's not related to privacy or security? As soon as you connect something to the Internet it's related to privacy and security.

The only situation where privacy and security don't matter a whole lot is if your code runs on airgapped devices with very limited tasks.

Re:Kent Beck: “I get paid for code that works, not for tests... by EpicEng on Thursday December 08, 2016 @10:38AM (#13130908)
I rarely write code that connects to anything, so almost never? There's a lot of code that's not written by web devs.
Re:Kent Beck: “I get paid for code that works, not for tests... by hannob on Thursday December 08, 2016 @10:52AM (#13131040)
> I rarely write code that connects to anything, so almost never?

Sounds hard to believe. What kind of code would that be?

> There's a lot of code that's not written by web devs.

There's also a lot more than the web that has some form of connectivity with the Internet (even if it's not directly connected it may still parse data that comes from untrusted sources).

There is a widespread belief among many that "security is important, but doesn't matter for me". The most extreme example is obviously IoT ("Who would want to hack my coffeemaker?"), but there's a lot more. The unfortunate truth is: There is hardly any code these days that is not security relevant.

Re:Kent Beck: “I get paid for code that works, not for tests... by EpicEng on Thursday December 08, 2016 @12:03PM (#13131838)
I write code that interfaces with hardware (health care imaging systems), processes images, and a little computer vision here and there. Very few service calls in that stack.

I jump up 1000 levels of abstraction from time to time, and when I do, I agree that security is extremely important (FDA class III device and HIPAA compliance is mandatory.) I'm also a lead, so I have to know enough to call BS when I hear it from a team member.

Re:Kent Beck: “I get paid for code that works, not for tests... by ryandrake on Thursday December 08, 2016 @11:25AM (#13131401)
> > I rarely write code that connects to anything, so almost never?

> Sounds hard to believe. What kind of code would that be?

Device drivers, compilers, and some embedded systems come to mind immediately, there are plenty of others out there. I've worked on a lots of software where the only inputs were physical and sensor based, and the only outputs were to the screen. Device didn't even physically have network equipment.

Re:Kent Beck: “I get paid for code that works, not for tests... by RandomOpinion on Thursday December 08, 2016 @11:42AM (#13131581)
>...device drivers...

I hope you're joking but I suspect you're not. Device drivers have the highest level of privileged access in many operating systems and code quality for drivers is so uniformly lousy (certain large vendors whose names begin with "N", "A", and particularly "Q", I'm looking at you) that attempting to break the drivers would be among the first things I'd consider if I were trying to root a device.

Re:Kent Beck: “I get paid for code that works, not for tests... by ryandrake on Thursday December 08, 2016 @12:08PM (#13131889)
Please see my other reply. I was addressing "unconnected software" not "software without attack surfaces". I agree that security is a concern with all software.
Re:Kent Beck: “I get paid for code that works, not for tests... by boomlinde on Saturday December 10, 2016 @01:37PM (#13147099)
Well, in a sense, a device driver can usually be thought of as very connected to a highly sensitive part of a computer system. If something goes wrong in a driver it will have a negative effect on the whole (monolithic) kernel and the rest of the operating system.
Re:Kent Beck: “I get paid for code that works, not for tests... by hannob on Thursday December 08, 2016 @11:31AM (#13131454)
Device drivers are a bad example, they can be extremely security sensitive (particularly so because they usually have kernel privileges).

There are few things where security doesn't matter. But they are extremely rare. The situations where programmers think their code isn't security sensitive are probably vastly more common.

Re:Kent Beck: “I get paid for code that works, not for tests... by ryandrake on Thursday December 08, 2016 @11:46AM (#13131629)
Good point, but I was addressing the perceived lack of "code that connects to anything". I agree with you that security is a valid concern for most if not all code written.
Re:Kent Beck: “I get paid for code that works, not for tests... by nickpsecurity on Thursday December 08, 2016 @11:22AM (#13131364)
"Sounds hard to believe. What kind of code would that be?"

You do realize there's a bajillion non-networked apps in existence? Word processors, excel, editors/IDE's, system tools (esp monitoring/backup), media players that don't download stuff, compression libraries, MATLAB-style tools for numeric analysis, and so on.

Re:Kent Beck: “I get paid for code that works, not for tests... by hannob on Thursday December 08, 2016 @11:28AM (#13131432)
> You do realize there's a bajillion non-networked apps in existence? Word processors, excel, editors/IDE's, system tools (esp monitoring/backup), media players that don't download stuff, compression libraries, MATLAB-style tools for numeric analysis, and so on.

All of them parse potentially untrusted inputs. They don't have to be directly network connected to be a security risk.

Just pick the first example: A word processor. It is not a security risk only if you can guarantee that you'll only ever open documents that you created yourself. If you ever use it to open documents you got from someone else it needs to take security into consideration.

Re:Kent Beck: “I get paid for code that works, not for tests... by mwexler on Thursday December 08, 2016 @12:14PM (#13131950)
Sadly, almost everything you mention involve opening files, and files are often on networks. Standard modal file|open on windows allows http:// access to files on hosted servers, for example. Suddenly, all of these are potentially networked in the hands of users using the code for unintended purposes or in unexpected ways.
Re:Kent Beck: “I get paid for code that works, not for tests... by Jtsummers on Thursday December 08, 2016 @12:25PM (#13132072)
But you don't write those dialogs yourself. You write code that calls the system file open dialog. Then, presumably, you do some check on the file for sanity checking (is it the right type? does it parse correctly? does the internal size # equal the value the OS is claiming?). If those checks fail, you report an error. Otherwise, you process it. The source doesn't matter at that point. And if there's a glitch in the dialog for handling HTTP or similar sources, then that's on the system developers to correct, and on you to report if you discover it.
Re:Kent Beck: “I get paid for code that works, not for tests... by nickpsecurity on Thursday December 08, 2016 @02:11PM (#13133137)
Exactly. All the concerns of networking, the Internet, and the Web go away. It becomes an input validation problem. From there, one can do a format suitable for correct-by-construction auto-generation of the parser. Or can take the common route building a Turing machine into it to fight with over time. ;)

Still not writing or patching a networked app.

Re:Kent Beck: “I get paid for code that works, not for tests... by Jtsummers on Thursday December 08, 2016 @02:21PM (#13133247)
OT: Have you ever read Engineering a Safer World [0] by Nancy Leveson [1]? Seems like something that'd be of interest to you. Started on it this week, my sister is in her class this semester at MIT. I'll be tackling it over the next few weeks, and then her previous text (Safeware) after the new year.

[0] https://mitpress.mit.edu/books/engineering-safer-world

[1] http://sunnyday.mit.edu/

Re:Kent Beck: “I get paid for code that works, not for tests... by nickpsecurity on Thursday December 08, 2016 @09:19PM (#13136175)
Wow. Been studying high-assurance systems close to 10 years and just hearing about her. That's how scattered that field can be. Let's look at this.

"Started new area of research: software safety." That was Bob Barton in Burroughs B5000, Dijkstra on THE, and Margaret Hamilton on Apollo code. Maybe they mean first dept at MIT or just making status of sub-field more official. Then TCAS II. I recall reading that long ago as an exemplary work in formal specification & safety analysis but project was too heavy for me. Article says them too haha. Props to her for it & others. Article shares my view on scattered groups & methods. At least seen STAMP referenced once but unfamiliar with it. They wrote against N-version programming being re-invented... which I proposed for subversion resistance. Hmmm. I'm sure my variant is the one that works this time. ;) Also did SpecTRM at their company that looks a lot like state machine and modeling schemes I saw elsewhere in high-assurance. Not claiming a copy rather than inspiration or independent invention + convergence of multiple parties. Usually means a good idea.

Very interesting person. Thanks for the tip. Your sister is going to learn some wise things for sure given they've got sane methods and got results before. I especially liked how the article jokes about writing what she knew on high-assurance development then gotten wiser or more confused. I know the feeling where I'm redoing the foundations now with what a decade taught me. More slowly this time given I have more doubt than certainty.

Note: Just got to the last part. Wait, she was the one who wrote the THERAC paper? I just assumed it was some guy (male-dominated field) named Levenson since that name was all I saw in references to the report. Never saw it again. So, she wrote up an investigation we've been citing about software safety for decades, helped spearhead efforts to legitimize it as a field, did huge projects, and I basically never hear about her. Unreal. I'm bookmarking her stuff to go through it later.

Re:Kent Beck: “I get paid for code that works, not for tests... by Alex3917 on Thursday December 08, 2016 @10:56AM (#13131091)
Right, I meant that in the context of things that tests are designed to catch. E.g. almost no one writes tests to look for unsafe eval or whatever.

A good example is that I care a lot about making sure our search endpoint doesn't return private user data. But beyond that, I'd rather just know that the endpoint returns a 200 and let someone tell us if it's broken rather than have an extra three hundred lines of code to see if it's returning the correct results. If we get a ton of users then that will probably change, but for now the cost of writing and maintaining those extra tests wouldn't be worth the benefit.

Re:Kent Beck: “I get paid for code that works, not for tests... by mannykannot on Thursday December 08, 2016 @02:47PM (#13133560)
> The only situation where privacy and security don't matter a whole lot is if your code runs on airgapped devices with very limited tasks.

That used to be true for the software in cars, but it no longer is. The problems that result are not the fault of the original authors; that belongs to the people who decided to bridge the airgap without thinking through the consequences.

Re:Kent Beck: “I get paid for code that works, not for tests... by tlrobinson on Thursday December 08, 2016 @10:54AM (#13131070)
Most client-side web app code doesn't have much bearing on privacy/security, aside from avoiding XSS and a few other pitfalls.
Re:Kent Beck: “I get paid for code that works, not for tests... by wvenable on Thursday December 08, 2016 @11:56AM (#13131744)
> We write tests to be able to change it in the future

Which works great as long as your changes are shallow. If your changes aren't shallow then you have to change your tests as well and that defeats the purpose.

Automated testing is good for freezing an interface and it's behavior; allowing you to change implementation while maintaining the same outputs. Lots of technology requires this: Networked API endpoints, libraries, etc.

But most change I encounter is from changes in requirements that necessarily requires reworking and re-arranging code that won't be compatible with the test suite.

Re:Kent Beck: “I get paid for code that works, not for tests... by Jtsummers on Thursday December 08, 2016 @12:27PM (#13132089)
Different types of tests. You can have tests of the whole system which should always pass. Then there's unit tests, which may have to be removed/updated (though again, this depends on your scale of units). Some you expect to fail after a change to requirements get incorporated. Others you expect to pass, and you react accordingly.
Re:Kent Beck: “I get paid for code that works, not for tests... by olavk on Thursday December 08, 2016 @12:31PM (#13132118)
If the code is designed following the single responsibility principle, and tests are written to test behavior rather than implementation details, then each requirements change should only affect the tests which specifically test for the behavior which changes.
Re:Kent Beck: “I get paid for code that works, not for tests... by wvenable on Thursday December 08, 2016 @12:45PM (#13132268)
That's still a very narrow view of changes; the belief that you can isolate every part and that requirements changes would then only affect those isolated parts seems is pure fantasy.

I've had to completely redesign entire subsystems; break down components into different pieces; move code between different layers; etc.

Honestly as a manager nothing bothers me more than developers who try and patch complex changes into existing systems without re-thinking how it affects everything else. I have to re-factor a project that's a total mess because code was added but not removed or changed over the course of some very big requirements changes. I'm sure all the tests pass but it's impossible to follow now.

The problem with unit tests is it adds an extra layer of friction on making changes that benefit the product. You are actively discouraged from changing your design from your initial assumptions! This change friction can be seen as a benefit if you need all your interfaces to be stable (like with a library). But it's a trade off and it's not appropriate everywhere.

Re:Kent Beck: “I get paid for code that works, not for tests... by olavk on Thursday December 08, 2016 @05:58PM (#13135094)
Yeah you can have bad architecture with or without tests, having tests does not mean you don't have to think about design! I disagree that tests lock you down though, it really depends on how they are written.
Re:Kent Beck: “I get paid for code that works, not for tests... by wvenable on Thursday December 08, 2016 @06:26PM (#13135299)
You can't have unit tests that don't lock you down to a particular structure of units. That's really the definition of unit testing.

I'm not saying anything about bad architecture. You have a good architecture for today's requirements that is a bad architecture for next year's requirements. Tests lock you down to whatever your first architecture is.

Re:Kent Beck: “I get paid for code that works, not for tests... by olavk on Friday December 09, 2016 @02:45AM (#13137344)
I tend to avoid the term unit-test since there is some disagreement about what "unit" mean. Some think it means testing everything down to the level of individual private methods. This will indeed lock you down. And if it paired with extensive "mocking", where you only ever test that method A calls method B when invoked, then yes, you have locked your self down and you wont get a lot of value from the tests.

I prefer automated tests of larger units or subsystems, and testing against requirements, protocols and specifications rater than implementation details would change. Of course anything will change over time, but I believe this kind of tests provides higher value and lives longer.

Re:Kent Beck: “I get paid for code that works, not for tests... by misja111 on Thursday December 08, 2016 @10:43AM (#13130948)
There are a couple of reasons why you should/ could write tests:

- for catching regressions in the future

- to verify that your code works. How else would you know that your backend service reacts properly on some edge condition

- as documentation

- as a kind of quality mark, for instance to be able to pass a code review or when writing code for an external party

Unfortunately the last reason is also the most useless and still it is the one that seems to be the main motivation for many big enterprise developers.

Re:Kent Beck: “I get paid for code that works, not for tests... by TallGuyShort on Thursday December 08, 2016 @10:49AM (#13131005)
>> - as documentation

Thank you for including this - it's underappreciated. So many times recently I've needed to write code against some poorly documented API (not always due to lack of effort, some things are hard to document well in prose / JavaDocs, or just due to constant change), but I took one look at the unit tests and it all made sense - and I knew it was up to date for the latest work.

Re:Kent Beck: “I get paid for code that works, not for tests... by Freak_NL on Thursday December 08, 2016 @10:59AM (#13131122)
Tests are great for dyslexic colleagues as well. A good clear concise unit test is often easier to grasp than the best of API documentation (e.g., JavaDoc in Java).
Re:Kent Beck: “I get paid for code that works, not for tests... by TallGuyShort on Thursday December 08, 2016 @12:03PM (#13131831)
Good point - I'd bet it applies to autism and such too.
Re:Kent Beck: “I get paid for code that works, not for tests... by euyyn on Thursday December 08, 2016 @04:25PM (#13134442)
I think it applies to everybody. I think it was Terence Tao who had a blog post claiming (and showing) that teaching by example first is the most effective.
Re:Kent Beck: “I get paid for code that works, not for tests... by mannykannot on Thursday December 08, 2016 @02:51PM (#13133601)
I know this is not formally an ordered list, but it looks cart-before-the-horse-ish to have catching future regressions before verifying that it works in the first place. (This comment is effectively a reply to the OC's claim that we don't test to verify.)
Re:Kent Beck: “I get paid for code that works, not for tests... by Touche on Thursday December 08, 2016 @09:12AM (#13130350)
The quote is not anti-test. You should read the article.
Re:Kent Beck: “I get paid for code that works, not for tests... by andrewstuart2 on Thursday December 08, 2016 @09:45AM (#13130552)
And we write tests to exercise our own assumptions about how the system will be used. It's way too often I write some tests for my code, I quickly arrive at use cases and failure cases that I hadn't anticipated while writing for the optimal use case.

Reality, on the other hand, is usually suboptimal.

Re:Kent Beck: “I get paid for code that works, not for tests... by Quarrelsome on Thursday December 08, 2016 @09:58AM (#13130636)
yes but if you follow that too strongly you end up having to rework tests _every_ time you change something which is absurd.

You should be testing input/output and results as opposed to testing how the internal gubbins works. That's the line we have to carefully tread when making a test. The test shouldn't force the item to behave in directly the way it expects; more that the I/O is correct.

Re:Kent Beck: “I get paid for code that works, not for tests... by demonshalo on Thursday December 08, 2016 @10:15AM (#13130766)
this is essentially the argument for functional tests over unit tests and while I generally agree, I think a mixture of the two is important.

Unit tests should be used for extremely small and isolated mission critical objects while functional tests should generally cover the entirety of the I/O chain. That's how I do it at least and it works extremely well for a fraction of the cost!

Re:Kent Beck: “I get paid for code that works, not for tests... by iopq on Thursday December 08, 2016 @11:23AM (#13131373)
I've never seen any value in unit tests. They never fail. What's the point?
Re:Kent Beck: “I get paid for code that works, not for tests... by astrange on Thursday December 08, 2016 @12:35PM (#13132162)
They're useful if the code changes, or if the code doesn't change but the runtime/compiler under it does and breaks it. This can definitely happen in large projects.

If your project breaks because of local changes I think regression tests with real data and bisecting is better and less work though.

Re:Kent Beck: “I get paid for code that works, not for tests... by iopq on Thursday December 08, 2016 @01:33PM (#13132770)
There are a few scenarios:

1. Your unit tests fail basically every time anything changes. This is the scenario where your unit test is something like "the command line arguments are -abcd" and every time you add one you need to change the test. This makes the unit test worse than useless, but actually a source of extra work every time you change something.

2. Your unit test never fails. It just doesn't fail ever, at all, under any circumstance. It's so obvious that it should work, but someone wrote that test anyway. It's a waste to run it every time.

3. Your unit test fails when you refactor because it tested some internal functionality. You need to throw away your unit test every time you refactor. It's a waste to write one every time.

The only tests that ever show that a refactor broke something are integration tests. The 200+ unit tests in my project either NEVER fail. Except for that one that you have to keep changing every time.

Re:Kent Beck: “I get paid for code that works, not for tests... by sethammons on Thursday December 08, 2016 @11:14AM (#13131274)
How do you test error conditions? In my experience, you are typically not mocking hardly anything (ideally nothing) with functional tests and some error cases require mocking. I find unit tests helpful in this arena.
Re:Kent Beck: “I get paid for code that works, not for tests... by crdoconnor on Thursday December 08, 2016 @11:58AM (#13131761)
I mock things all the time with functional tests. It makes it easier to reliably test your code's response to unusual conditions (e.g. error conditions) and it eliminates a source of brittleness in the test (you can write functional tests that hit the real paypal API and run them every day but every 2nd Friday they will fail because paypal is shit at keeping their servers up).

This is in no way a benefit unique to unit tests.

Re:Kent Beck: “I get paid for code that works, not for tests... by gr3yh47 on Thursday December 08, 2016 @10:02AM (#13130661)
> yes but if you follow that too strongly you end up having to rework tests _every_ time you change something which is absurd.

it depends how brittle your tests are. You can write tests that make sure internal stuff works at a unit level without them being so brittle

to your point testing I/O or behavior is the way to accomplish this, but it can still be done at the level of internal functions/methods

Re:Kent Beck: “I get paid for code that works, not for tests... by moron4hire on Thursday December 08, 2016 @10:56AM (#13131094)
This is why I generally prefer demos and saved REPL sessions to tests. I really care about avoiding regression, not about whether or not a certain function returns or errors on certain values. It's all about not getting lost in the weeds.
Re:Kent Beck: “I get paid for code that works, not for tests... by smallnamespace on Thursday December 08, 2016 @08:58AM (#13130255)
'Code that works' doesn't necessarily mean 'code that only works today'. I'm pretty sure maintainability is implied in his statement.
Re:Kent Beck: “I get paid for code that works, not for tests... by alkonaut on Thursday December 08, 2016 @09:53AM (#13130597)
If maintainability is part of "works" and tests are a necessity for maintainability (they are), then the quote becomes prettu weird. Substituting [code and tests] for [code that works] gives

> I get paid for [code and tests] not for tests.

Re:Kent Beck: “I get paid for code that works, not for tests... by smallnamespace on Thursday December 08, 2016 @10:03AM (#13130669)
The discussion was around what the right level of testing is.

> I get paid for [code that works and is maintainable], not [more tests than are strictly necessary to achieve that goal]

Re:Kent Beck: “I get paid for code that works, not for tests... by alkonaut on Thursday December 08, 2016 @10:51AM (#13131029)
Yeah, that's the reasonable interpretation (which is also backed up by the full article). As usual the quote is taken out of context and/or put into a headline that's deliberately much more inflammatory than the actual article.
Re:Kent Beck: “I get paid for code that works, not for tests... by pif on Thursday December 08, 2016 @09:58AM (#13130631)
> I'm pretty sure maintainability is implied in his statement.

I don't know this guy, so I can't speak for him in particular. But, in general, I wouldn't be surprised if the opposite was true: too many so-called software developers give "shipping" too much importance, leaving none for any other aspect of the job. Shipping is a feature, not the feature.

Re:Kent Beck: “I get paid for code that works, not for tests... by switchbak on Thursday December 08, 2016 @11:59AM (#13131774)
Kent Beck brought developer testing to prominence in the early 2000's with his books on XP and particularly TDD.

Back in those days, there was a backlash against "big design up front", and very little respect (in general) for testing as a practice. Unit testing in it's modern form was reasonably rare.

After this Agile/TDD stuff caught on, many people ended up over-testing things. This is a pretty typical thing to do when you're learning about how much testing is sufficient. I've definitely done a good amount of this myself.

It can take a good deal of experience to know where to draw the testing lines in particular contexts. I think this blog post points at this specifically - that we should write high-value tests, and just enough of them. We also use feedback over the long-term to have heuristics of where we tend to have recurrent issues, so we can test a bit more in those areas.

Far from being focussed on "only shipping", he's underlining the fact that "just enough well-written tests" support working software - and that should be our focus, instead of thinking our job is to "write more tests" (or focus on test coverage, etc).

Re:Kent Beck: “I get paid for code that works, not for tests... by imarg on Thursday December 08, 2016 @10:30AM (#13130861)
If by "I don't know this guy" you mean Kent Beck then you should google him[1].

This is not some random guy, he is like the "father" of TDD. And that is why the guy that wrote the article thought it noteworthy to mention his quote.

If it came from someone else it would not be that important to make such a fuss about it. But when it comes from Kent Beck then it is worthy at least some discussion.

[1] https://en.wikipedia.org/wiki/Kent_Beck

Re:Kent Beck: “I get paid for code that works, not for tests... by squeaky-clean on Thursday December 08, 2016 @10:43AM (#13130949)
> I don't know this guy, so I can't speak for him in particular.

Literally the second sentence in the article.

> Kent Beck, respected authority, creator of Extreme Programming, TDD and writter of several great reference books, mainly at the great Addison-Wesley edition

Re:Kent Beck: “I get paid for code that works, not for tests... by fortytw2 on Thursday December 08, 2016 @08:59AM (#13130259)
Removing implicit side-effects and global state from code and having strong, static types can go very far in allowing this, without much overhead.

Unfortunately, there isn't a really great language that enforces working like this, while being simple enough to push onto a big team :/ (if there is, please let me know)

Re:Kent Beck: “I get paid for code that works, not for tests... by bpicolo on Thursday December 08, 2016 @09:17AM (#13130378)
F# is probably a pretty decent candidate for this (it's next on my list of languages to really take a critical look/attempt at).

I've done a lot less statically-typed code than dynamic (mostly Python) in the last few years, but I was playing with Unity3d recently and had a chance to write a good deal of C# with Visual Studio.

I hit a hairy problem some time along and had to do a big refactor to support a new feature. I deleted a single line of code, followed an error trail for 10 minutes, and suddenly everything was just done.

It was a pretty interesting moment for me. I realized that statically-typed languages can really have the potential to be as or more productive than dynamically typed languages paired with a good enough IDE. (And Visual Studio with C# is about the best pairing you can get).

I've had to reconsider my thoughts on these things a bit. Sure, there are things that statically typed languages can make much harder to test or work with. (Want to stub an external provider? Okay, you're going to need an extra interface, then you'll need to create a new stub version that implements that. Want to read/write pretty-arbitrary JSON? Good luck). But there are other places where you get huge wins by bugs just disappearing by the boatload.

I'm still not on board with heavy OO/inheritance, and love the pattern of simpler struct-style constructs with just functions in functional programming, but the static typing can give a lot of wins.

I think something that gives an inherent advantage to OO languages in IDEs is that SomeThing.<tab autocomplete> makes a lot of sense and is easy to compute! I can take an object and know what I can do with it at a glance. I haven't seen a functional language with enough structure to support that simple feature yet (though maybe I'm just not looking hard enough). This is really where statically typed languages can make the most of an IDE. For some reason, that's the big thing I think of when I'm thinking about the downsides of functional programs I'm working with. The editors just seem to help a lot less (though I haven't written any FP professionally-speaking, so have less experience in general with tooling).

F# using Records with member methods looks like it might be able to get that sort of benefit though, I'll need to try that. It looks like they're just pure functions declared on immutable structs, which I think is the perfect middle ground.

A lot of object-oriented languages have taken tips from functional languages lately (map/reduce/filter is the new hottie), but I think there's a lot of benefit still to get in the opposite direction.

Re:Kent Beck: “I get paid for code that works, not for tests... by johncolanduoni on Thursday December 08, 2016 @09:37AM (#13130495)
> I think something that gives an inherent advantage to OO languages in IDEs is that SomeThing.<tab autocomplete> makes a lot of sense and is easy to compute!

F# (as well as OCaml) offers something similar in that you'll use a lot of functions that are within modules with the same name as the type you're working with. So you can write "List." and get a list of functions (map, reduce, etc.). I'd prefer something like Idris which will disambiguate functions based on the relevant types, but at least it makes IDE support easier.

> A lot of object-oriented languages have taken tips from functional languages lately (map/reduce/filter is the new hottie), but I think there's a lot of benefit still to get in the opposite direction.

Something in particular I wish F# would add it general non-linearity of definitions. All files and definitions in F# must be strictly ordered (either type A can reference type B or vice versa, but not both) except for specific, contiguous blocks. It presents a challenge for type inference, but I think just punting it back to you for the tricky cases would be fine (and it often has to do this anyway).

Re:Kent Beck: “I get paid for code that works, not for tests... by Nelkins on Thursday December 08, 2016 @10:46AM (#13130974)
I like having the linearity of definitions and files. It makes reading unfamiliar code bases much easier, as it means the code has a "beginning" and "end." To me it fits well with the F# theme of sensible defaults.

If you do need to get around it though, you can have mutually referential types in F# if you use the "and" keyword (although the definitions of the types have to be right next to one another). And in the next update to F# you'll be able to have mutually referential types and modules within the same file which is often good enough for most other things you might need that sort of thing for.[1]

[1] https://blogs.msdn.microsoft.com/dotnet/2016/07/25/a-peek-in...

Re:Kent Beck: “I get paid for code that works, not for tests... by johncolanduoni on Thursday December 08, 2016 @12:44PM (#13132244)
I think the linearity can force you to streamline things, but personally I often have to resist the urge to bike-shed the order in which I write functions in the same file, let alone what order I want to put my files in. I end up being torn between different orders I would want in different situations, and would love a language or IDE that would let me view definitions in different orders depending on what I'm looking for.
Re:Kent Beck: “I get paid for code that works, not for tests... by bpicolo on Thursday December 08, 2016 @10:14AM (#13130757)
I suspected as much, thanks for confirming! F# is definitely the plan for this weekend, then :)
Re:Kent Beck: “I get paid for code that works, not for tests... by to3m on Thursday December 08, 2016 @10:13AM (#13130749)
I don't find dynamically-typed languages productive at all once the program gets past about 400 lines and/or you figure out what you need to do.

The break-and-follow-the-errors approach is very powerful. It's usually not hard to find the exact break that will show you all the things you need to change, and then just work through them. My record is 5 days without buildable code, working in C++; once I'd worked through all of the errors, the program worked, and without any non-obvious problems.

I miss this a lot when working in a dynamically typed language.

(Thing by Jonathan Blow that touches on this: https://web.archive.org/web/20140929232443/http://lerp.org/n...)

Re:Kent Beck: “I get paid for code that works, not for tests... by vurpo on Thursday December 08, 2016 @09:54AM (#13130607)
> Want to read/write pretty-arbitrary JSON? Good luck

Parsing JSON in Java was one of my worst programming experiences, so I have to agree with you here.

But in Rust, using the `rustc-serialize` library (and Serde, but I haven't tried that yet), parsing and writing JSON is really pretty painless. The really nice part is that you can declare the structure of your JSON data as a completely normal Rust struct (just with a derive annotation that makes it Encodable and/or Decodable), and with a single function call turn an instance of that struct into a JSON string. And in reverse, you can just parse() a string and it will return either an instance of your struct or an informative error if the JSON is malformed or doesn't match your structure. Makes JSON really easy to work with.

Re:Kent Beck: “I get paid for code that works, not for tests... by andrewaylett on Thursday December 08, 2016 @10:44AM (#13130959)
Jackson (in Java) gives you pretty much the same experience, albeit I'd recommend a few annotations on your object. And you can read/write arbitrary JSON into JsonNode or Map<> objects.
Re:Kent Beck: “I get paid for code that works, not for tests... by bpicolo on Thursday December 08, 2016 @10:11AM (#13130733)
I think 'arbitrary' was actually the key word. I agree that serializing/deserializing structs is pretty painless, the issue is when you're not sure what you're getting.

In golang recently I had to take some json (that I only knew part of the structure of), and modify just that small subpart of it without touching the rest. It was a really painful thing to develop, and the code ended up very messy.

There were a few golang libs for reading arbitrary json, but none supported writing to it that I could find.

Re:Kent Beck: “I get paid for code that works, not for tests... by hota_mazi on Thursday December 08, 2016 @03:31PM (#13133999)
> Want to read/write pretty-arbitrary JSON? Good luck)

I'm surprised this myth perdures.

Reading arbitrary anything is trivial in a statically typed language: use a hash map.

There. You're merely emulating what a dynamically typed language gives you, of course, but it's trivial. And at least, statically typed languages give you the choice: you can be dynamic or static. You don't have such a choice when you don't have types.

Re:Kent Beck: “I get paid for code that works, not for tests... by naasking on Thursday December 08, 2016 @10:11AM (#13130730)
> I realized that statically-typed languages can really have the potential to be as or more productive than dynamically typed languages paired with a good enough IDE.

Indeed, and C# isn't even a particularly safe typed language. It still has pervasive null, for instance. When you get into F#/OCaml/Haskell/Rust-type languages, it's a real eye opener.

> Want to read/write pretty-arbitrary JSON? Good luck

Not sure I see the problem. Just deserialize JSON into a JsonValue which provides dictionary semantics like JavaScript.

Re:Kent Beck: “I get paid for code that works, not for tests... by couchand on Thursday December 08, 2016 @09:35AM (#13130480)
I agree the property reference tab autocomplete is a pretty powerful feature. It's like autocomplete in a shell, but contextual, since the system already knows what you want the first argument to be. And I've seen a video with one of the big functional guys (maybe Brian Beckman?) pining for that feature.

I'd point out, though, that is still is only part of the picture. You're holding on to a value and you want to know what you can do with it:

    widget.<tab>
will show you everything of the form

    widget.someData
    widget.doSomething()
but you're still missing out on other structures like

    freeFunction(widget)
    handler.handleWidget(widget)
    hammer + widget
    widget[part]

    // returns a widget, does this one count?
    widgetFactory.buildWidget()
In nearly any language the first two will be common, and where available the others are critical usages, too. I want to be able to tab complete them!

It's hard to continue hewing to the tab as activation with these other structures, which may be why IDEs and REPLs don't really try.

Re:Kent Beck: “I get paid for code that works, not for tests... by taeric on Thursday December 08, 2016 @09:43AM (#13130536)
That sounds like something that would be an awesome demo, but not really useful.

I actually dislike tab complete in usual forms most times. Auto import is nice, but i feel that auto complete is a form of searching the code base. And, when I am coding seems a poor tube to be searching for the answer.

When debugging, however, jump to symbol and quickly listing alternative methods helps. And sometimes I am just searching. So, good feature. Just not something i want to rely on.

Re:Kent Beck: “I get paid for code that works, not for tests... by bpicolo on Thursday December 08, 2016 @10:12AM (#13130746)
In large code bases it can be really hard to keep everything in your head, and that's when a little tab complete can really come in handy. Just forgetting specific method names when you know there's one you want to use can be very handy.
Re:Kent Beck: “I get paid for code that works, not for tests... by taeric on Thursday December 08, 2016 @10:46AM (#13130983)
It can help. Often does. But I treat it like spell check. If I need it, I'm probably using the wrong word. And I don't know how to use it to effectively search for words.
Re:Kent Beck: “I get paid for code that works, not for tests... by fbonetti on Thursday December 08, 2016 @10:16AM (#13130772)
In terms of web languages, Elm is perfect for this purpose. It's a statically typed, pure functional programming language. It's impossible for functions to generate side effects. Side effects must captured by the type system as external "Commands". Also, the type system is inspired by Haskell but far more basic. To hardcore functional programmers this is a negative, but Elm is really easy to teach to JavaScript programmers as a result.
Re:Kent Beck: “I get paid for code that works, not for tests... by Arnt on Thursday December 08, 2016 @08:59AM (#13130260)
That's one reason to write tests.

Another is that some code reviewer asks for more tests. A third reason to spend time on tests is that they're required to maintain the same standard as the shipped code, even though they're only run in the presence of the developers, and their breaking only affects the developers, not any customers.

People forget the ultimate reason for our work oh so often.

Re:Kent Beck: “I get paid for code that works, not for tests... by agentultra on Thursday December 08, 2016 @09:08AM (#13130327)
I don't have that kind of hubris. I value reliability, repeatability, and consistency. And so do my customers by tell of the issue reports we get. They're most upset when something goes wrong.

I write tests, many tests, when I'm working in a dynamically typed programming language. I write tests even when I'm working in a soundly typed language. The only difference is that in soundly typed languages the type system guarantees many properties for me so I don't test for those.

Personally I like to write tests first but I don't believe that gives me any productivity benefits. It's just the way I think.

> People forget the ultimate reason for our work oh so often.

Tests are important because reliable code is important. The customers are important but so is the business. It costs quite a lot of money to support error-prone, poorly designed software. Tests aren't a silver bullet but they are a tool to alleviate the problem.

Re:Kent Beck: “I get paid for code that works, not for tests... by Arnt on Thursday December 08, 2016 @11:28AM (#13131430)
I've heard words much like those many, many times, but always in general or specific to a context where it didn't apply.

For example when I changed some code for which tests didn't exist, so I tested what I changed and wrote some extra tests while I was at it, and it was blocked in code review because my extra tests didn't report failure in any detail. What I did said "x failed" if a test failed, no details. The reviewer said much the same as you did now to justify that additional reporting was absolutely required.

It's a fine sentiment when it actually applies, and I wish it weren't applied quite to often to justify YAGNI and other rubbish.

Re:Kent Beck: “I get paid for code that works, not for tests... by switchbak on Thursday December 08, 2016 @11:47AM (#13131637)
Can you say specifically what you object to in his words above? I'm failing to connect what he said with your complaint.

The advice you received with regards to defect locality sounds reasonable - tests that don't give much in the way of isolation can cost a lot of developer time to hone in on. It's hard to say, not knowing the exact details however.

I also find it hard to reconcile the idea that "tests are an important tool for writing good software" with "justifying YAGNI". How would an "openness for developer testing" justify an attitude of "not writing things you don't need"? Those two concepts sound almost entirely orthogonal.

Re:Kent Beck: “I get paid for code that works, not for tests... by Arnt on Thursday December 08, 2016 @12:19PM (#13132003)
Unit tests are important to that goal. But that doesn't make every aspect of every unit test important as such.

Specifically, if a test passes right away, then its error reporting isn't important today. It probably comes in useful if the test ever breaks, but will the test ever break? Therefore, spending significant time on the error reporting today is YAGNI, even if minimal version of the test is useful.

My complain is that even if unit tests are useful to a degree, people trot out the reasons for usefulness primarily when those reasons do NOT apply.

Re:Kent Beck: “I get paid for code that works, not for tests... by st3v3r on Thursday December 08, 2016 @01:35PM (#13132796)
I cannot disagree more. If you are bothering to write a test in the first place, do it right. There is nothing worse as a developer than receiving a ticket or a user report saying "It broke; fix it" with no other information.

Not to mention it will literally take you 2 minutes to add the better reporting.

Re:Kent Beck: “I get paid for code that works, not for tests... by switchbak on Thursday December 08, 2016 @07:24PM (#13135632)
Ok, I see what you're getting at there.

So if it takes you significant time to get proper defect locality, I think you should see if there's a better way to approach the problem. This should be essentially the default for typical/modern unit tests. Perhaps you're writing tests that are more like system level tests?

I'd also say that if you're essentially certain a test will never break, then (other than for documentation purposes) why are you writing it? To paraphrase Kent Beck - we should only test things that could possibly break.

You might be overgeneralizing what "people" say about unit tests - I'm not sure what your specific scenario is, but there are a whole spectrum of opinions on the subject. Perhaps this is just an organizational code-smell of the place you're mentioning.

Dogmatism/cargo culting in general can be annoying however.

Re:Kent Beck: “I get paid for code that works, not for tests... by RandomOpinion on Thursday December 08, 2016 @11:50AM (#13131676)
>What I did said "x failed" if a test failed, no details.

Yuck. Imagine if you got a bug report that just said "X failed" with no details.

Re:Kent Beck: “I get paid for code that works, not for tests... by terryf on Thursday December 08, 2016 @09:23AM (#13130407)
The first part of your comment sounds really odd to me. I definitely write tests to check if my code works, among other things.

Why do you think that is the wrong approach?

Re:Kent Beck: “I get paid for code that works, not for tests... by nolemurs on Thursday December 08, 2016 @09:48AM (#13130563)
It's not that it's wrong. Having confidence your code works is ultimately the goal. That said, if I just need to know code works, manual, rather than automated testing works just as well, and requires less effort.

Automated testing only shows its real value when you go back to change code that was working before. With the manual approach you'd have to retest everything to have any real confidence. With the automated approach you just run a command.

I'm a big fan of automated testing, but if I didn't expect to have to ever change code, I wouldn't bother with it.

Re:Kent Beck: “I get paid for code that works, not for tests... by shados on Thursday December 08, 2016 @10:32AM (#13130878)
"Automated testing only shows its real value when you go back to change code that was working before"

end to end tests, integration tests, regression tests, etc, yeah.

Unit tests though...usually no. Often if you're making any kind of significant change, the entire code paths may get refactored away or change too much and the test will get nuked anyway.

And it's that kind of test that usually confuses people, so it's worth understanding.

A unit test's goals are many:

It proves at authoring time that the code works. It saves you the time right away of having to go through the UI or spinning up a server just to validate a function is working. It proves that you thought about specific edge cases (and if you do testing consistently, the lack of test is your evidence of unconsidered edge cases. It's documentation of all of the things you considered when writing the code. It is an example of how to use the code with all it's use case.

And when you nuke a piece of code away, the failing tests are now a guide of all the cases you have to make sure are truly no longer necessary.

If, in the future, you do a refactor of an implementation detail (so the existing tests are still valid), then that's bonus as you get green/red validation. But in practice, that is less common than all of the other reasons for testing. That's why the "I don't expect this to change" thing isn't really a reason for or against writing tests.

Re:Kent Beck: “I get paid for code that works, not for tests... by laserDinosaur on Thursday December 08, 2016 @10:58AM (#13131107)
>Unit tests though...usually no. Often if you're making any kind of significant change, the entire code paths may get refactored away or change too much and the test will get nuked anyway.

That pretty accurately describes my experience with unit tests. I've been part of several projects where we had pretty comprehensive unit tests (I'd say small to medium sized projects) and I never managed to get as much use out of unit tests as I liked. After one or two big refactors most of the tests needed to be, as you said, nuked anyway. While seeing all the pretty green lights is reassuring, they are rarely working when you most need them - during large refactors which blows away big sections of code.

I picture unit tests as a row of black boxes sitting on a table in certain positions. Unit tests are great when you don't move the black boxes but do change the mysterious processes are running inside them. But refactoring is rarely ever that isolated in programming since you tend to move some of the black boxes around, remove some entirely, add some new ones, change the contents. To then expect the unit tests to give you back useful information on whats broken is rarely possible.

I've had more success with e2e testing using things like Selenium, but it's still frustrating as a developer to read articles about how great unit testing is (like this root comment) and never able to actually get a decent working version of it in your projects (because of the reasons mentioned by this parent comment).

Re:Kent Beck: “I get paid for code that works, not for tests... by Jach on Thursday December 08, 2016 @03:00PM (#13133717)
The biggest benefit I've been seeing from unit tests is in writing more of them inside a code base sorely lacking them. In that case there's a big side-effect of making the underlying code unit-testable (that is, if you don't totally cheat every time with something like PowerMock). Some tests may get blown away in refactoring, but testing the new code has the same benefit. In many cases this makes the implementation uglier but doesn't hurt its clarity much (oftentimes it can improve it), especially with IDE assistance.

Building up small oases of dumber/more verbose code that has unit tests seems like the best way to wrangle legacy code into something that anyone else on the team can understand and not mess up 6 months from now when it's their turn to have to touch it for the first time. Of course no one wants to touch that 200-line, 10-levels-of-indentation monster method, but bringing just a little bit more and more of it under unit test over time will help a lot. Every other benefit of unit testing that you listed besides the time saving aspect (e.g. why launch a big e2e test if you can test the same thing in an xunit-like context? even if it's not strictly a "unit" test) pales in comparison of the benefit of making crap code nicer to work with. A corollary is that if your code is already nice to work with, and you have a system to keep it that way, unit tests won't be very valuable. (Though other tests, which may or may not be in an xunit-like context, may still be quite valuable.)

Re:Kent Beck: “I get paid for code that works, not for tests... by mistermann on Thursday December 08, 2016 @10:04AM (#13130677)
Just being the devil's advocate....

> With the manual approach you'd have to retest everything to have any real confidence.

This kind of implies that software development before "~tdd" was a complete disorganized gong show of quality especially where refactoring, but in fact that was not the case. There are ways of coding that are more conducive to quality than others.

> With the automated approach you just run a command.

Once you've written all that code, yes.

> if I didn't expect to have to ever change code, I wouldn't bother with it.

Usually you don't, in which case the extra effort on testing is wasted, usually.

Re:Kent Beck: “I get paid for code that works, not for tests... by nolemurs on Thursday December 08, 2016 @11:24AM (#13131393)
> This kind of implies that software development before "~tdd" was a complete disorganized gong show of quality especially where refactoring, but in fact that was not the case.

The question isn't "do we need to test." Testing can just take the form of running the code manually and making sure the output makes sense, but you do need to test.

The question is "do we test automatically or manually." It's the same question regardless of how good your practices are. Note that this is totally distinct from the question of whether or not to use TDD.

> Once you've written all that code, yes.

I've found that writing tests often doesn't take much longer than testing manually, and rarely takes longer than testing manually twice. Sure, if you obsessively try to test every possible case and input, you'll waste time, but well targeted testing doesn't have to be slow.

> Usually you don't, in which case the extra effort on testing is wasted, usually.

For non-trivial projects I have an average number of revisions per line of code much closer to 2 than to 1. Sure, some of the code only gets written once and never touched, but other code gets revised multiple times. If you're good at writing tests, the tests will focus on those often revised lines of code.

And, again, you have to compare the effort against the effort of manual testing, not against the effort of writing code you've never run and shipping it.

Re:Kent Beck: “I get paid for code that works, not for tests... by dpark on Thursday December 08, 2016 @11:15AM (#13131285)
You usually don't have to make changes to code once you've written it? The only time I ever find that true is when the code is throwaway (ad hoc data crunching for some purpose, scripts to automate some one time tedious process, practice projects just intense to learn a system, etc). I don't think I've ever written anything that was useful for more than, say, a week that didn't get changed later by myself or someone else.

The typical claim is that code maintenance is at least 10x as long as the initial write.

Re:Kent Beck: “I get paid for code that works, not for tests... by robotnoises on Thursday December 08, 2016 @09:29AM (#13130442)
To me there are two automated testing philosophies:

1. Write tests to prove your code works, which is sometimes referred to as "test-driven development"

2. Write tests to catch any side effects or regressions when altering code

Funny thing is that if you write good tests, then the results are pretty much the same regardless of your motivation.

Re:Kent Beck: “I get paid for code that works, not for tests... by marcosdumay on Thursday December 08, 2016 @10:08AM (#13130716)
You have to:

1. Have an overall idea of what your software will do before writing the first line of code.

2. Challenge and change any touched assumption from #1 during development when you refine that idea.

3. Test that the program satisfies your refined idea after it's written.

4. Create some assurance you'll keep #3 correct while you write any further code later.

However you fulfill those needs, if you got them all, you are good.

Re:Kent Beck: “I get paid for code that works, not for tests... by cheez on Thursday December 08, 2016 @09:26AM (#13130425)
I spent some time working for one of the biggest names in trading technology and one of the things I learned is that if your code doesn't work on more or less the first try, your design is probably wrong. The implications of that lesson are profound.

When something doesn't work as expected, I now check my design and not the code.

Re:Kent Beck: “I get paid for code that works, not for tests... by pc86 on Thursday December 08, 2016 @09:29AM (#13130436)
> if your code doesn't work on more or less the first try, your design is probably wrong

Or you're tired. Or you're just not as focused as you could be. Or you have a deadline. Or you're trying something new. Or you're not fluent in the language yet. Or you're fluent in the language but not the framework. Or you're fluent in the language and framework but not the design pattern (if you use those).

Or a whole host of other things.

I'm not saying spot-checking the design isn't a good idea, but saying that it's the design more often than the code just doesn't match up with my experience.

Re:Kent Beck: “I get paid for code that works, not for tests... by cheez on Thursday December 08, 2016 @10:27AM (#13130845)
The entire idea is to increase the probability that you are correct. So if you're coding tired, you're decreasing that probability. If you're using a framework you're not familiar with, you're decreasing that probability. This is why I mentioned that it was in trading technology: they only get paid to be right.
Re:Kent Beck: “I get paid for code that works, not for tests... by lordnacho on Thursday December 08, 2016 @09:40AM (#13130522)
How do you define "the first try"? Surely you're bound to have various trivial issues?
Re:Kent Beck: “I get paid for code that works, not for tests... by cheez on Thursday December 08, 2016 @10:23AM (#13130818)
Something along the lines of after fixing obvious stupid things like those trivial issues.
Re:Kent Beck: “I get paid for code that works, not for tests... by d_theorist on Thursday December 08, 2016 @10:14AM (#13130756)
I remember once my code worked on the first try. I found it difficult to believe.
Re:Kent Beck: “I get paid for code that works, not for tests... by cheez on Thursday December 08, 2016 @10:28AM (#13130848)
One time in uni, I had no access to a computer and wrote an entire b-tree implementation on paper for a course, typed it in and it worked.

Based on a true story

Re:Kent Beck: “I get paid for code that works, not for tests... by eveningcoffee on Thursday December 08, 2016 @07:38PM (#13135712)
In principle TDD is the opposite of this.

Out of curiosity, did you use any debugging on paper for your code?

Re:Kent Beck: “I get paid for code that works, not for tests... by cheez on Thursday December 08, 2016 @07:45PM (#13135756)
I can't recall, honestly
Re:Kent Beck: “I get paid for code that works, not for tests... by jimmaswell on Thursday December 08, 2016 @10:31AM (#13130869)
I've found it to happen very often the past few years
Re:Kent Beck: “I get paid for code that works, not for tests... by throwayawnotime on Thursday December 08, 2016 @10:14AM (#13130758)
Did this comment really deserve a downvote? Upvoting accordingly!
Re:Kent Beck: “I get paid for code that works, not for tests... by pc86 on Thursday December 08, 2016 @10:35AM (#13130892)
Maybe not, but this one certainly does.
Re:Kent Beck: “I get paid for code that works, not for tests... by clifanatic on Thursday December 08, 2016 @10:06AM (#13130690)
> Why do you think that is the wrong approach?

"Because you should write code that works in the first place!" -- your boss

Re:Kent Beck: “I get paid for code that works, not for tests... by Steeeve on Thursday December 08, 2016 @06:26PM (#13135306)
Absolutely. The article itself (it's a short one) talks about doing just enough tests to have confidence in a product, and I think that's fantastic for early phase development.

But when changes can come from anywhere (lots of developers potentially making changes) and the need for changes can be urgent, there's a great deal of value in complete code coverage.

Not every developer thinks the same or has the same tendency for errors. I would caution people against thinking about tests as personal verification. With any luck, you'll be handing off that code base to someone else in time.

Re:Kent Beck: “I get paid for code that works, not for tests... by hinkley on Thursday December 08, 2016 @04:44PM (#13134574)
When I start thinking of some of my code as safety equipment, and some like shop tools, a lot of my decision processes become more straightforward.

My tests and practices are, occasionally, like a five point harness in a race car. Without it anchoring the driver in front of the wheel, they could never ever drive that fast with any safety at all. This one comes out as a counter to the 'straightjacket' argument some people like when the tools won't let them just write shit code that the rest of us have to babysit while they run off somewhere else to write more shit code. Which we are supposed to be grateful for... I digress.

But most of the time my tests are more like smoke detectors. The ones that go off for no reason get replaced or removed. The ones that go off after I can see fire and smell smoke? Why am I paying for upkeep on those exactly? What's the value?

Re:Kent Beck: “I get paid for code that works, not for tests... by jsight on Thursday December 08, 2016 @11:41AM (#13131572)
I have seen codebases where the developers diligently insured that every getter and setter method had a test case. They had great test coverage, but not particularly reliable outputs.

OTOH, projects with excellent end-to-end tests tend to have lower coverage but better regression management.

I think this is the point of the article?

Re:Kent Beck: “I get paid for code that works, not for tests... by eveningcoffee on Thursday December 08, 2016 @07:49PM (#13135774)
I think that this is one of the points.

I think that full test coverage is nor sufficient or necessary for the working software. What matters is the sufficient covering of the edge cases.

I think that an additional point to keep in mind is that most probably Kent Beck talked mostly from the point of statically typed languages.

Re:Kent Beck: “I get paid for code that works, not for tests... by zebraflask on Friday December 09, 2016 @02:08AM (#13137228)
That's not a bad perspective, but the counterpoint that I have seen several times is that the tests can tend to take on a split quality where some will insist that nothing can be changed if a test has to be changed along with it - and then the other camp steps in and doesn't want to put in the effort for new tests, so the existing ones get removed.

Testing makes a lot of sense if you're doing data munging, but for front end or other kinds of code that are almost defined by their ability to create side effects, it's usually a waste of time. In my humble.

Re:Kent Beck: “I get paid for code that works, not for tests... by randomdata on Thursday December 08, 2016 @11:55AM (#13131721)
Technically, we write tests to document what the code does. We could use any language, including english, to do that. However, using a programming language carries the side benefit of being able to allow automatic verification that the documentation is at least in sync with the code (although not necessarily accurate with respect to the project goals).
Re:Kent Beck: “I get paid for code that works, not for tests... by sidlls on Thursday December 08, 2016 @12:45PM (#13132266)
And then who or what documents the tests? Test code is code. That's important and all too often that fact is sort of elided.

"We" write comments and use "plain" language documentation, or formatted but otherwise plain language for documentation generators to parse to document our code, and that includes "what the code does."

I'd argue that if your test code is what you're relying on to "document what the code does" then you are probably (almost certainly) over-testing, testing the wrong things, or some combination. Oh, and also using test code incorrectly (as documentation).

Re:Kent Beck: “I get paid for code that works, not for tests... by mrmrcoleman on Thursday December 08, 2016 @08:12PM (#13135870)
This is entirely subjective as it comes down to Kent's sense of what needs to be tested, which is arguably a better 'sense' than that of many other programmers.

Do you allow your juniors to use their sense? No, you make them hit 100% coverage until they start to learn.

As Paul McCartney said: "Learn the rules like a pro, so you can break them like an artist."

Re:Kent Beck: “I get paid for code that works, not for tests... by fsloth on Thursday December 08, 2016 @10:27AM (#13130843)
"But we don't write tests to check if our code works."

If the input data is complex enough to drive a non-trivial branching logic in our code - yes we do. Well, at least I do. The bonus is that it provides the fixed point for further changes at the same time.

Re:Kent Beck: “I get paid for code that works, not for tests... by gaius on Thursday December 08, 2016 @10:09AM (#13130720)
We write tests to be able to change it in the future with certain degree of confidence that we don't break anything and - if so - what exactly

You don't want tests for that - you want a type system and a static analyzer.

Re:Kent Beck: “I get paid for code that works, not for tests... by jon-wood on Thursday December 08, 2016 @10:34AM (#13130885)
A type system and static analysis certainly allow you to stop writing a certain category of test as you no longer need to assert that a method being passed an object of the wrong type copes with that. It doesn't completely relieve of you the need to test though as a type system won't assert that the code you're writing actually fulfils the businesses requirement that nothing can be ordered for same day shipping after 11am.
Re:Kent Beck: “I get paid for code that works, not for tests... by gaius on Thursday December 08, 2016 @12:23PM (#13132040)
You absolutely can do that with the type system, use a constrained subtype.
Re:Kent Beck: “I get paid for code that works, not for tests... by jon-wood on Friday December 09, 2016 @06:19AM (#13138086)
You've got my interest piqued now. How does that work in practice? And do you not still need to test that it complies with the actual business rules at some point?
Re:Kent Beck: “I get paid for code that works, not for tests... by raldi on Thursday December 08, 2016 @10:31AM (#13130872)
How does that confirm to you that, say, your ratelimiter code is correctly processing the first three requests in a given minute, rejecting the fourth, and approving a fifth once another minute has passed?
Re:Kent Beck: “I get paid for code that works, not for tests... by cm2187 on Thursday December 08, 2016 @10:11AM (#13130737)
But only tests will tell you you are calculating something correctly.
Re:Kent Beck: “I get paid for code that works, not for tests... by digi_owl on Thursday December 08, 2016 @10:12AM (#13130742)
But thats anathema to agile, yo. /s
Re:Kent Beck: “I get paid for code that works, not for tests... by EGreg on Thursday December 08, 2016 @11:38AM (#13131535)
So then why don't you just write the tests BEFORE you are about to refactor something or change some interface? Why write them at "launch time" of the feature?
Re:Kent Beck: “I get paid for code that works, not for tests... by st3v3r on Thursday December 08, 2016 @02:10PM (#13133122)
Because if you haven't written them, odds are the code is not particularly well suited to be testable. Side effects out the wazoo, tight coupling, etc.
Re:Kent Beck: “I get paid for code that works, not for tests... by 0xdeadbeefbabe on Thursday December 08, 2016 @02:45PM (#13133533)
That only works if you run the tests often. Writing them is less important than running bits of your program often enough to discover how it really works.
Re:Kent Beck: “I get paid for code that works, not for tests... by partycoder on Thursday December 08, 2016 @03:56PM (#13134211)
Tests can be seen as a form of executable documentation, or a executable specification, a sort of self-enforcing contract.
Re:Kent Beck: “I get paid for code that works, not for tests... by vikiomega9 on Thursday December 08, 2016 @02:08PM (#13133108)
N00b question, what's another technique? I mean if tests are assertions on assumptions is there something better?
Re:Kent Beck: “I get paid for code that works, not for tests... by gshulegaard on Thursday December 08, 2016 @12:59PM (#13132423)
This is the right answer. I will also point out that as a result of this property collaboration becomes easier.
Re:Kent Beck: “I get paid for code that works, not for tests... by mannykannot on Thursday December 08, 2016 @03:15PM (#13133867)
> But we don't write tests to check if our code works.

So what methods do you use for that purpose?