- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Well, maybe the string builder is like really slow and you need to be patient ...
Admin
Damn, all these times where I've been in a hospital, I would have never suspected that the Patient instances were also JavascriptStringBuilder instances !
Admin
brilliant.string()
Admin
Really a 5-word coding horror story.
Admin
brillant.string()
FTFY
Admin
Or more likely "composition over inheritance".
Admin
Of course it should be noted all JS objects already define a .toString() which is meant to serve this purpose anyway. No need to inherit, just define your own .toString(). Which just makes this extra stupid.
Addendum 2024-02-19 09:49: EditL oh yeah, and presumably they're not using any of the capabilities of the string builder, just blowing away .string () with their own. So no inheritance is needed anyway, especially since JS is typeless.
Admin
Rarely have I felt so gobsmacked by so clear and succinct a bit of code. As Vera said. That's one for the record books.
I am greatly enstupidated by having this added to my repertoire of syntactically correct statements.
Admin
Yup, usually there's something to be figured out, so when I hit the "here's the code" part of the post, I'm usually ready to do some logical thinking and "well if this, then that" simulations.
Not this time. I hit "JavascriptStringBuilder" and the only thought in my head was "well, would you look at that", and I stared at that one class name for like a full half a minute. There's really nothing to say about it, is there?
Admin
This isn't JavaScript, I think it's Java, which is very strongly typed.
But I think they're using
extends
when they should be usingimplements
. But that's for interfaces, not classes, so it's still not right.Admin
public class Patient extends JavascriptStringBuilder public class Doctor extends InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonPainter public class Nurse extends SimpleBeanFactoryAwareAspectInstanceFactory.getAspectClassLoader public class Coder extends PaulaBean(brillant, 1, TRUE, FALSE, FILE_NOT_FOUND) // what a germ ...
Admin
Assuming they want to convert the
Patient
to a JSON document, the right way to do this is to use Jackson or one of its competitors. Depending on how you've set up the class, you might need to plop down some simple annotations, but for typical use cases you don't even need to do that.Admin
Meat for doctor Jackson.
Admin
Henceforth, "enstupidated" is going into my everyday vocabulary.
Admin
Along with George W Bush's "misunderestimate" and Corey Doctorow's "enshittification", it's a very useful piece of a modern vocabulary. And one I invented on my own, although I may not be the first / only.
Admin
Java also has a toString method on the Object class which every other class extends automatically.