News for hackers. Stuff that matters.
Re:DRY is an over-rated programming principle? by jsiaajdsdaa on Thursday July 07, 2022 @05:29AM (#32011715)
if those 8 lines of regex have been unit tested and the function is commented to describe "what" the code does, it is entirely the point that you don't need to understand how it works

additionally, the function should be stateless and have no side effects ;)

Re:DRY is an over-rated programming principle? by gjulianm on Thursday July 07, 2022 @05:35AM (#32011753)
How do you test 8 lines of regex inside a function that does more things? And what's easier, to write and read the function name or copy-paste the lines with the comment (if the comment explaining what that piece does is even written, that is)?
Re:DRY is an over-rated programming principle? by jsiaajdsdaa on Thursday July 07, 2022 @09:20AM (#32013725)
i'm a bit confused, do we need to know the nitty gritty details of how Math.random() is written, or that it will reliably give us a random double?
Re:DRY is an over-rated programming principle? by _ZeD_ on Thursday July 07, 2022 @06:02AM (#32011949)
you dont you mock the function that have the regex with a fixed behavior and check the actual logic inside the wrapper function