8

From the book

Refactoring JavaScript
Turning Bad Code into Good Code
Evan Burchard

HOW CONVERSATIONS ABOUT REFACTORING SHOULD GO UNTIL TESTS ARE WRITTEN
“I refactored login to take email address and username.” “No, you didn’t.”
“I’m refactoring the code to ____”
“No, you aren’t.”
“Before we can add tests, we need to refactor.” “No.”
“Refactoring th–”
“No.”
“Refa–” “No.”

Comments
  • 8
    A fine example of the problem with current software development philosophy and it's unbridled, unthinking love of all things testing related. That right there is unthinking dogma. Every test has a cost. Every test is code. That conversation is one that simply demonstrates a mindset that does not consider those things. What if the resting was difficult? What if the tested feature was minor? Is it Ok the spend $1000 to write a test for a $10 feature (always assuming a manual test will take place)? Companies are chewing through $$$ at an incredible rate as a result of blithely performing actions with a high negative ROI, all for little to no gain in quality. Because it's dogma.
  • 9
    "I refactored login to take email address and username."

    No, you didn't refactor anything, you changed the functionality.
  • 0
    @monkeyboy Wrong think. I hear ya though. I feel like test writing is a make work project for our industry. I would think otherwise if anyone gave 2 shits about tests actually testing something. The concept is right. The implementation is garbage.
  • 0
    @monkeyboy also, IT is trendy. Decision makers do not deal well with bucking trends. When something goes wrong, some dipshit consultant will tell their boss that their guy did not do something that is industry standard at the given moment. Who is going to put their neck on the line that way?
  • 2
    @funkyboss , I think we're in the same ballpark: "dogma" mostly the same as your "make work". I think the "right" implementation involves some common sense rather than doing things by rote. So, in some cases "write tests for everything first" is actually the right thing. Other times, it's not.
  • 0
    @monkeyboy Few author tests that test anything. Even fewer author code that is testable in a meaningful way. Is it covered? That is not so hard. Does the test tell you when something is broken? (for real) It does not seem like it to me. It is dogma at that point. I completely agree.
  • 0
    @monkeyboy

    (yes I have a google alert on myself... sooo)

    You might like the section on "uses until modification," a definition of "spiking," and "confidence" that I provide, as well as Opdyke's thesis for a fuller discussion.

    I'm joking about the term being used imprecisely, not claiming TDD is the only way to work.
Add Comment