this post was submitted on 20 Nov 2024
214 points (98.2% liked)

Programmer Humor

32611 readers
44 users here now

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

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] parpol@programming.dev 7 points 2 weeks ago (14 children)

Surely we all write unit tests and debug from there, right?

... Right?

[–] CanadaPlus@lemmy.sdf.org 3 points 2 weeks ago* (last edited 2 weeks ago) (12 children)

Depending on what kind of coding you're doing, there might not be an obvious, really atomic unit to test. Most people here seem to do the data-plumbing-for-corporations kind, though.

[–] leisesprecher 3 points 2 weeks ago (11 children)

Especially then I'd test the shit out of everything? I'm getting paid for writing correct software.

[–] Dunstabzugshaubitze 2 points 2 weeks ago (1 children)

data-plumbing-for-corporations tends to be able to be done in a way that's easily testable, but also most people get paid to bolt on new shit onto old shit and spending time on "done" code is discouraged so once they fall behind on writing tests while developing the new shit those tests will never be written.

and bad developers that won't write tests no matter what actually do exist.

[–] CanadaPlus@lemmy.sdf.org 2 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

If I actually did have that kind of job, the tests-first philosophy would sound very appealing. Actually, build the stack so you don't have a choice - the real code should just be an instantiation of plumbing on generic variables with certain expected statistical properties. You can do that when correctly processing unpredictable but repetitive stuff is the name of the game, and I expect someone does.

[–] leisesprecher 3 points 2 weeks ago (1 children)

Tests first is only good in theory.

Unit tests typically test rather fine grained, but coming up with the structure of the grain is 80% of the work. Often enough you end up with code that's structured differently than initially thought, because it turns out that this one class needs to be wrapped, and this annotation doesn't play nice with the other one when used on the same class, etc etc.

[–] CanadaPlus@lemmy.sdf.org 1 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

Can't you just add the wrapper to the test as well, if it's easy to do in the actual code?

[–] leisesprecher 1 points 2 weeks ago (1 children)

If you have to ask "can't you just" the answer is almost always no.

[–] CanadaPlus@lemmy.sdf.org 1 points 1 week ago (1 children)

Well, yeah, but I was kind of hoping you'd explain why.

[–] leisesprecher 1 points 1 week ago (1 children)

Because you don't know what you'll need that wrapper beforehand, that's my entire point.

Unless you're only doing trivial changes, the chances are very high that you won't be able to design the class structure. Or, you end up essentially writing the code to be able to write the tests, which kind of defeats the purpose.

[–] CanadaPlus@lemmy.sdf.org 1 points 1 week ago

That's kind of the whole philosophy, though. The tests are the main way you understand what you're doing, the working code is just an addition on top of that. Presumably, there's a way to do that without repeating yourself - although I'm not turning up much on a quick look.

load more comments (9 replies)
load more comments (9 replies)
load more comments (10 replies)