793
Leave it alone (lemmyf.uk)
submitted 10 months ago by willya@lemmyf.uk to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] entropicdrift@lemmy.sdf.org 2 points 10 months ago* (last edited 10 months ago)

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

this post was submitted on 06 Jan 2024
793 points (96.4% liked)

Programmer Humor

32600 readers
586 users here now

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

Rules:

founded 5 years ago
MODERATORS