66
you are viewing a single comment's thread
view the rest of the comments
[-] lemmyvore@feddit.nl 2 points 1 year ago* (last edited 1 year ago)

Here's my take. In order to be able to write meaningful unit tests the code should be structured in a certain way, with very modular, decoupled units, dependency injection, favoring composition and polymorphism over inheritance and so on.

If you manage to write your code this way it will be an objective advantage that will benefit the project even if you don't write a single unit test. But it does make unit tests much easier to write, so presumably you'll end up with more tests than otherwise.

IMO teams should prioritize this way of writing code over high test coverage of non-modular code. Unit tests for deeply-coupled code are a nightmare to write and maintain and are usually mostly meaningless too.

[-] bleistift2@feddit.de 1 points 1 year ago

This. Just thinking about how you would test something leads to better code, at least in my experience.

this post was submitted on 28 Jun 2023
66 points (98.5% liked)

Programmer Humor

19503 readers
368 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS