Ice cold take: You don’t have enough tests if you can’t safely refactor on a whim.

A well-tested project should allow you to refactor arbitrarily. As long as all existing tests pass, rewritten code is at least functionally equivalent to the previous code. This allows for fearless performance rewrites, refactoring, and even complete redesigns of components.

In other words, the tests are more valuable than the code itself. The spec for the codebase proper should be defined by the tests. When the spec changes or grows, the tests should change or grow, and then the main codebase should be modified to pass all tests once again.

TL;DR TDD evades this issue entirely and is fantastic for larger and/or longer-term projects

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 77 users / day
  • 211 users / week
  • 413 users / month
  • 2.92K users / 6 months
  • 1 subscriber
  • 1.53K Posts
  • 33.8K Comments
  • Modlog