When it works.
No, seriously, that's the prime criteria. I'll take crap code over good code anytime, it it works and the "good" code needs some arcance and/or bizar setup procedure that I have to put up with to perhaps get it running.
Point in case: WordPress, a PHP driven Web CMS that today runs about 20% of all websites, is a huge pile of typical PHP spagetti. And don't even get me started on the data model
I mean, just look at it! (Surgeon Generals Warning: Looking at WP code can cause instant heart problems and depression!)
It was quite an adventure.
However, it works. My grandma can setup WP in 10 minutes. Come around the corner with your flashy new Java whatnot, clean model and all, if I spend more than a week trying to get it runing on Debian or some other widespread Linux, I will ditch it, no matter how well the app itself is coded.
Programms are for users, and they have to work. The rest is icing. End of story.