this post was submitted on 14 Feb 2026
333 points (99.7% liked)

Programmer Humor

29726 readers
2408 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 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] WhiteRice@lemmy.ml 1 points 18 hours ago* (last edited 18 hours ago) (1 children)

Can you override Math.random within a local scope?

At my shop we do create generic covers for vendor specific functionality, for the reasons you stated. Though the practice was started in case we ever needed to swap vendors.

[–] bleistift2@sopuli.xyz 6 points 14 hours ago

You can, but you shouldn’t. You don’t know what else relies on Math.random. That’s why there’s the wrapper function. That you can override in unit tests without worrying about other, unrelated code.