News for hackers. Stuff that matters.
Re:The 4-chan Go programmer by zimpenfish on Wednesday August 28, 2024 @03:53PM (#41383538)
> I have seen a single line of code passed through 4 "interface functions"

I once had to deal with a HTTP handler that called `Validate` on interface A which called `Validate` on interface B which called `Validate` on interface C which called `Validate` on interface D which finally did the actual work. There was a lot of profanity that month.

Re:The 4-chan Go programmer by Cthulhu_ on Wednesday August 28, 2024 @04:03PM (#41383644)
I mean to a point that makes sense; you got your base data types like idk, a bank account number which can be validated, which is inside a bank account which can be validated, which is in a customer which can be validated, etc etc. Visitor pattern style, I believe?
Re:The 4-chan Go programmer by binary132 on Wednesday August 28, 2024 @04:10PM (#41383710)
imagine allowing invalid values to exist
Re:The 4-chan Go programmer by withinboredom on Wednesday August 28, 2024 @04:23PM (#41383880)
This is actually my preferred approach. If you want to put a 4gb base64 as your phone number, go right on ahead; best believe I will truncate it to a sensible length before I store it, but sure. Who am I to question your reality.

Sadly, people abuse shit like that to pass messages (like naming Spotify playlists with messages to loved/friends/colleagues while in jail) and maybe we have to assert a tiny bit of sanity on the world.

Re:The 4-chan Go programmer by steezeburger on Wednesday August 28, 2024 @05:59PM (#41384892)
How do prisoners have access to Spotify?
Re:The 4-chan Go programmer by ozr on Wednesday August 28, 2024 @09:25PM (#41386303)
Presumably some feature/jailbreak of JPay (and the like) tablets.

https://offers.jpay.com/jp5-tablets/

Re:The 4-chan Go programmer by ozr on Wednesday August 28, 2024 @04:17PM (#41383807)
Sounds awful.
Re:The 4-chan Go programmer by quectophoton on Wednesday August 28, 2024 @04:27PM (#41383950)
> imagine allowing invalid values to exist

Pretty common, for example when using databases as a mostly dumb store with all the logic in application code, and then a second application (or big refactor) appears and they introduce a subtle bug that results in an invalid `INSERT` (or whatever), and the database happily accepts it instead of rejecting it.

Re:The 4-chan Go programmer by agency on Wednesday August 28, 2024 @04:33PM (#41384025)
imagine enforcing invariants as part of the design of a software system
Re:The 4-chan Go programmer by nickpeterson on Wednesday August 28, 2024 @05:33PM (#41384654)
The nerve, taking good jobs away from young qa testers. Wait till the IT Union hears of this!
Re:The 4-chan Go programmer by binary132 on Wednesday August 28, 2024 @10:24PM (#41386644)
I’m just saying enforce invariants at construction time / type-designing instead of with the validity checks
Re:The 4-chan Go programmer by zimpenfish on Thursday August 29, 2024 @04:07AM (#41388456)
This wasn't that kind of validation - it was "is this token allowed to do this thing?" Like "validate your parking" kind of scenario.

(And yes, it should probably have been "CheckAuthorisation")

Re:The 4-chan Go programmer by binary132 on Friday August 30, 2024 @10:04AM (#41400859)
naming things is so hard.
Re:The 4-chan Go programmer by zimpenfish on Wednesday August 28, 2024 @04:36PM (#41384061)
That would make sense but this was one piece of data being validated against a lookup based off that data. The previous devs just had a, uh, Unique™ style of development. I swear they must have been on some kind of "editor tab count" bonus scheme.
Re:The 4-chan Go programmer by layer8 on Wednesday August 28, 2024 @05:23PM (#41384547)
This can happen when some of the interface operations have added logic, but others (like Validate here) don't, so just get delegated as-is.

One typical example is a tower of wrapped streams, where each layer applies additional transformations to the streamed data, but the Close operation is just passed across all layers to the lowest one (which closes the underlying file or whatever).