I wonder if the reverse has happened. Where a client pays for a project, and gets code, but it's terrible. So, open source it with attribution to the original developer and an appropriate README analysis of the low points.
Edit: Wondering if it has happened doesn't mean I'm promoting it as a terrific idea.
But why would you opensource terrible code? Even if you want to write an essay about bad practices, it sounds easier to write it just taking extracts to illustrate the points.
That said, attributing those extracts that you are criticizing would be pretty bad form, maybe even basis for a defamation suit. So, sounds messy either way.
Fine, what a terrible thing to do to an experienced coder.
As an industry, we work so hard to build a culture of constructive critique via code reviews, of mentoring up new developers, of constantly improving our skills. We strive not to judge people for their code any more than we would want to be judged for our own.
Naming and shaming coders because they wrote bad code is just uncool, as it fights against the aspects of this work that make it enjoyable, and instead turns it toxic.
If a client has richly rewarded you for your work in good faith, is it not also a terrible thing to deliver a pile of crap? If I pay a developer thousands of dollars and the result is garbage, you can bet I’ll be judging them for it.
If I paid a photographer to take my wedding photos and they did a terrible job, am I a bad person for judging and shaming them to warn others who might be similarly conned? Or is it only developers who get the kid gloves treatment?
Maybe the execution is shit but the idea behind it is interesting enough that you'll pick up some community developers that will code you something for free.
Said client probably picked the wrong people in the first place, and if they couldn't tell then how could they tell now?
I think most small-end jobs end up going to shit for more reasons than bad code, I'm still trying to understand the whole dynamic of how it all goes to crap.
I'd also just like to add if your hypothetical was the case would said developer ever care? I doubt it, they'd just move on to the next sucker.
Edit: Wondering if it has happened doesn't mean I'm promoting it as a terrific idea.