Kinda verbose, ain't it? Just speaking from my own personal experience, usually when I resort to print-debugging I'm already pretty punchy and more likely to use a quick "ASDFASD" or similar.
You can't automate checking for random strings, right?
You won't need to submit that particular string working at Google, right?
Confused sysadmins wondering if this is SOX code...
Seems easy enough?
No, but you can make the string configurable.
> Kinda verbose, ain't it?
I always used the word "doberman" for this purpose. I've never written code for a project that legitimately included the name of a dog variety. A simple grep for "doberman" in the production release CI pipeline catches it. If one ever did slip thru I figured it wouldn't be too offensive to anybody.
- Nothing happens
- Easy to find string in code, output, wherever
I occasionally need to override the hook, for example when using mktemp -t, or when some floating-point data actually contains a run of 9s. But mostly, it is quite specific at catching stuff that shouldn't be checked in.
This solves many of the concerns raised in this thread about readability, automation, avoiding typos in the magic string.
The tricky thing you have to solve is how to push the code that defines the custom logging function, but there are solutions.
I didn't want to make it too easy for people trying to crack our tools so, if such a problem were detected, the error message spat out to the console bore no relation to what had gone wrong.
By "bore no relation" I mean the error message would be one of a number of lines of dialogue from a scene in a House episode where House is trying to figure out who Wilson's girlfriend is... which led to this:
https://gist.github.com/gregoryyoung/871736
Yes, Greg Young (the event sourcing guy) ran into an error that said "Because I wanna ask you about your girlfriend. I must know who she is, or you would've told me her name," because he'd moved Smartassembly minus the licensing DLLs. Of course, he didn't realise what he'd done "wrong" so he tweeted it to his considerable following and it went viral.
Because I'm exactly the sort of walking cliche you'd expect I was blissfully unaware of the unfolding drama, being away on sabbatical snowboarding at the time. I hadn't taken my laptop with me, I'd disabled data roaming on my phone to avoid a whopper of a bill after a couple of months away, and had only a gen 1 iPad to access email and internet. So of course I came back in the evening to discover that it had all kicked off, with this ludicrous chain of emails where people were trying to figure out what was going on, until somebody had the sense to go and look in our source control system (which at the time was still svn for most things), and figure out that it was my fault.
People saw the funny side and it wasn't that big a deal but the reason I bring this up is that the last line of dialogue in that scene is, "Your mama," delivered by Wilson to House, and it was also the error message for the final failure scenario I was looking for. I'm glad that one didn't get printed.
However, if they missed one, it would move a random vertex by some random amount which is obviously very visible when rendering a 3D scene.
When people complained about this on forums (usenet mostly), they outed themselves for using pirated software.
To this day I still think Google’s motto only referred to “Do no System.exit(0)”.
Suddenly the customer tells us they have "repurposed" an "internally developed program" and they cancel our contract. The sales rep was upset that he would not be getting a commission on the sale and mentioned that he had "even sent them a demo", which led to the discovery of what had happened. My boss and I went to the customer's site to "finalize the paperwork", and when we were shown the application (which had extremely minor UI changes) I checked if the hidden click spot still worked, and it did! The customer was horrified. My boss was outraged.
We ended up getting paid the full contract amount plus a large bonus in exchange for agreeing not to sue. The sales rep decided to leave voluntarily rather than be fired.
Did you draw inspiration for it from Bullock's The Net (1995) by any chance?
This was all in the era of Gates' Open Letter to Hobbyists[1], when "Micro-Soft" was licensing their code to companies, perhaps because direct sales to hobbyists didn't work out.
[1] https://en.wikipedia.org/wiki/An_Open_Letter_to_Hobbyists
I remember a swearword appearing in a very big national company login form once, and I'd have felt sorry for the dev if it wasn't so hilarious.
Eventually it turned out that it was the single word "sheep" - which taken out of the relevant alt.* context was pretty harmless.
Talk about a moment when I thought my career had crashed and burned...
Please, do contextualize it?
One afternoon, I added the phrase "[Ww]ombo\s[Cc]ombo" (it supported regular expressions) and an expansion set (&prodbomb; evaluated to &wca; &wcb; to create "womb combo") but only in prod. In debug builds, it would produce "Wombat Combat"in bright red text.
This was a useful way to mark pages as "Don't build this in prod yet" - a habit some teams had of just yolo'ing their development branches right into production instead of doing a rebase to main. More than one build was saved by it within a few months.
Is nobody reviewing code before merging it upstream?
Every line was reviewed but that doesn’t mean it would be caught every time. And if it’s automatable to catch things like this it should be.
That's pretty good advice if you find yourself dealing with a large tech company.