Standing on the ankles of giants
June 10, 2010 3:14 AM   Subscribe

A great advance in computer engineering: introducing the "Doubleton"!!!!! A fascinating example of the intersection of uncritical thinking, mediocre implementation, and a solution in search of a problem resume padding.

The great thing about the web is it is not subject to editors. The terrible thing about the web is it is not subject to editors.
posted by orthogonality (64 comments total) 7 users marked this as a favorite
 
This is a really great idea!
posted by surrendering monkey at 3:27 AM on June 10, 2010


This is a really bad idea.
posted by surrendering monkey at 3:28 AM on June 10, 2010 [1 favorite]


This will work great with my Model-View-Controller-Modelviewer-Viewcontroller-Controllermodel pattern.
posted by fleacircus at 3:30 AM on June 10, 2010 [16 favorites]


Double.
posted by unSane at 3:40 AM on June 10, 2010 [5 favorites]


My "Zeroton" article is about to be published. No code snippets required, so even the layman can get a rich dark tan basking in my intense intellectual glow.
posted by loosemouth at 3:42 AM on June 10, 2010 [3 favorites]


My paradigm-shift sense is tingling...
posted by Philosopher Dirtbike at 3:44 AM on June 10, 2010 [1 favorite]


FPP could do with more context - for example with a link to what a Singleton pattern is and what this is reinventing (badly).
posted by Electric Dragon at 3:54 AM on June 10, 2010 [3 favorites]


I call dibs on "Tripleton"!
posted by Harald74 at 4:00 AM on June 10, 2010


i have seen so many instances of this in the last day or two that I suspect its a viral
posted by infini at 4:04 AM on June 10, 2010


you can tell authentic ugc from cheap fakes
posted by infini at 4:06 AM on June 10, 2010


*double take*
posted by Blazecock Pileon at 4:14 AM on June 10, 2010 [1 favorite]


I've been working on the linked linked list list, which is a linked list of linked lists.
posted by jenkinsEar at 4:18 AM on June 10, 2010 [1 favorite]


Read the author bio at the bottom, this is either comedy gold or a well executed joke.

Naveen Karamchetti has done his Masters (M.S.) in Software Engineering from B.I.T.S, Pilani and is based out of Fremont, CA.
The author has more than 12 yrs of experience in the IT industry, has started his career
starting from the good old days of using a Unix, Tcl/tk. The author has been associated with
several companies based out of Silicon Valley, California.

The author has won several programming awards within the organizations worked and is well-recognized. The author has also worked for Microsoft based at Redmond.

Hobbies include training, mentoring and research. Spends his free time travelling in the BART (Bay Area Rapid Transit) in Fremont, CA.


lolphasis, mine.
posted by atrazine at 4:22 AM on June 10, 2010 [2 favorites]


When you have a singleton and you already have one object, and you need another, where can you go? Nowhere. You're already maxed out.

But this pattern goes up to two. It's one object more.
posted by cotterpin at 4:23 AM on June 10, 2010 [27 favorites]


the irony is that you never know for certain
posted by infini at 4:23 AM on June 10, 2010


So, it's like Spinal Tap, but for programmers.

"It goes up to 2, see?"

"Why don't you use an object pool pattern?"

"But, It goes up to 2. It's one more."
posted by stavrogin at 4:26 AM on June 10, 2010 [4 favorites]


That's definitely a joke. Who uses C++ anymore?
posted by DU at 4:41 AM on June 10, 2010 [1 favorite]


I don't understand what this is about at all, but it is somehow making me feel better about my sad devotion to the ancient religion of procedural programming.

The only good thing an OO language ever brought into the world was //-style commenting. C ftw!
posted by A Thousand Baited Hooks at 4:41 AM on June 10, 2010 [4 favorites]


I'm going to advocate the negative-singleton, wherein someone else creates the object for me.
posted by readyfreddy at 4:59 AM on June 10, 2010 [3 favorites]


DU: "That's definitely a joke. Who uses C++ anymore?"

*Raises Hand*

I'm not that big a fan of it but it still seems to be used pretty extensively. According to Programming Language Popularity, it's still at or near the top of the charts.
posted by octothorpe at 4:59 AM on June 10, 2010


i have no idea what the fuck this is or why or whether i should try and eat it or have sex with it or what.
posted by dirtynumbangelboy at 5:03 AM on June 10, 2010 [6 favorites]


I invoke Poe's Law, or its corollary for Software Engineering.
posted by kandinski at 5:03 AM on June 10, 2010


i have seen so many instances of this in the last day or two that I suspect its a viral

Technically, you've only seen two instances, tops.
posted by yerfatma at 5:07 AM on June 10, 2010 [8 favorites]


According to Programming Language Popularity, it's still at or near the top of the charts.

In all seriousness, popularity is a terrible way to measure technical merit. I mean, look at the top of the list: Java. Ugh.
posted by DU at 5:13 AM on June 10, 2010


That's definitely a joke. Who uses C++ anymore?

Not him--that code is C#. But I use C++ daily. Still beats everything if speed and portability are the big concerns, IMO. (Except for C, of course, but how can you live without generics?)

I don't think this guy is a joke. Check out his profile; he's written 28 articles.
posted by equalpants at 5:13 AM on June 10, 2010 [1 favorite]


Uh, perhaps I should have said "I don't think this article is a joke." The guy himself is indeed a joke, I guess.
posted by equalpants at 5:24 AM on June 10, 2010


Malarky? Or effective way?
posted by munchingzombie at 5:25 AM on June 10, 2010 [2 favorites]


Wasn't this already covered in Bridget Jones: The Edge of Reason?
posted by tommasz at 5:27 AM on June 10, 2010


Well, it beats working in the local Memento Factory.
posted by swift at 5:31 AM on June 10, 2010


Out of interest, who would you have sex with if you had to choose between a singleton and a doubleton?
posted by doublehappy


I'm not sure I trust your motives in this situation.
posted by dirtynumbangelboy at 5:33 AM on June 10, 2010 [4 favorites]


tee hee
posted by infini at 5:40 AM on June 10, 2010


Related: the AtLeastTwoButNeverOne pattern.
posted by xthlc at 5:43 AM on June 10, 2010


Next up: the complex-ton, which has a real and an imaginary instance.
posted by unSane at 5:43 AM on June 10, 2010 [1 favorite]


If you had a lot of singletons and a bunch of spaghetti code, would that be a won-ton noodle soup?
posted by unSane at 5:45 AM on June 10, 2010 [1 favorite]


with shrimp and bok choy
posted by infini at 5:46 AM on June 10, 2010


DU: "According to Programming Language Popularity, it's still at or near the top of the charts.

In all seriousness, popularity is a terrible way to measure technical merit. I mean, look at the top of the list: Java. Ugh.
"

Well sure but I can't really say in a job interview, "Oh, I only program in languages that I approve of philosophically." I seldom get to pick the project that I work on or the language that use so it makes sense for me to know the most popular ones. Well except I refuse to learn C#.
posted by octothorpe at 5:56 AM on June 10, 2010 [1 favorite]


Guys Fuck Kill Marry

Singleton, Doubleton, Model-View-Controller-Modelviewer-Viewcontroller-Controllermodel

I would:

Fuck Singleton because I mean duh single amirite?
Kill Doubleton because a one night stand that can't take a hint will just get messy.
Marry Model-View-Controller-Modelviewer-Viewcontroller-Controllermodel because I think we have a lot in common. For instance, I control models body image issues using society's view against them
posted by edbles at 5:58 AM on June 10, 2010


object pool pattern

Also known as a fuckton.
posted by Mr. Bad Example at 6:02 AM on June 10, 2010 [4 favorites]


Well except I refuse to learn C#.

My set of refused languages has only one more than yours.
posted by DU at 6:07 AM on June 10, 2010


Zero-One-Infinity.

Fucking design patterns. Fucking Java.
posted by spaceman_spiff at 6:17 AM on June 10, 2010


DU: Wtf is your problem with Java? Everyone knows Python is for sissies who's code isn't hard-core enough to need multithreading and don't have enough discipline to indent their code properly without the compiler forcing them to do it!

(Ironically, if you want multithreading in python, you have to use Jython, which runs python on the Java virtual machine)
Well except I refuse to learn C#.
posted by octothorpe at 7:56 AM on June 10 [+] [!]
Heh.
posted by delmoi at 6:24 AM on June 10, 2010 [3 favorites]


What an office prank!

Replace your co-worker's Singleton with a Doubleton when they're not looking.
posted by ruthsarian at 6:39 AM on June 10, 2010 [1 favorite]


My problem with Java is that I've seen it spewing in millions of fragile, terribly-engineered lines from the fingertips of n00bs for a decade. That and it's overly-verbose and dogmatic Everything Must An Object Even Things That Aren't Objects philosophy. Don't even get me started on Java + XML. Double ugh.
posted by DU at 6:40 AM on June 10, 2010 [1 favorite]


*burp*



does a rapid glance around room for modchek
posted by infini at 6:45 AM on June 10, 2010


Huh, we use threaded Python natively without any Java crap involved. Works fine.
posted by octothorpe at 6:53 AM on June 10, 2010 [1 favorite]


Hmmmmmmm....

nods appreciatively and taps chin with steepled index fingers in a vain hope that others will be convinced he has the slightest clue of what this means to anyone.

Anywhere.

Ever.

posted by Samizdata at 7:34 AM on June 10, 2010 [2 favorites]


Also looks at octothorpe's comment and desperately fights off the urge to say something about wanting the removal of Oedipus complex suffering Aspidites melanocephalus from the vicinity.
posted by Samizdata at 7:38 AM on June 10, 2010




When all you have is an Abstract-Tool-Factory-Factory-Factory, everything looks like an Abstract-Metal-Fastener object.

Yep. In the old days, we called this "premature optimization" with the variable prematurely optimized here being "generality".

Here's how you make software:

1) Build the simplest thing that works.
2) In the future, if you find it no longer works, goto 1.
posted by DU at 7:59 AM on June 10, 2010 [3 favorites]


I thought it might have been a joke, until reading through the comments showed that in it's first incarnation, it didn't even work as advertised - It gave you instances 1 through N, and then instance 1 for every request thereafter. So it was basically a singleton with N-1 red-headed step children.

LOL MCSDs
posted by bashos_frog at 8:21 AM on June 10, 2010


My problem with Java is that I've seen it spewing in millions of fragile, terribly-engineered lines from the fingertips of n00bs for a decade
What does that have to do with the language? Python is even more n00b friendly and eventually tons of garbage code will be written in it too. It's easier to use then C++, which it slowly replaced. I assume you hate C and C++ too because people wrote bad programs in them?
That and it's overly-verbose and dogmatic Everything Must An Object Even Things That Aren't Objects philosophy. Don't even get me started on Java + XML. Double ugh.
First of all, java has both objects and primitives. One of the biggest complaints from people who don't actually use it is that primitives aren't objects so you have to use separate containers for them, although they recently added auto-boxing so you can have collections of doubles and stuff. And functions aren't objects either, obviously.

But beyond that, what are you talking about? What, specifically do you think is an object in java that shouldn't be? Are you just complaining about the three extra lines of code you have to copy and paste to start a new java program with a static main function in an object? Or are you just repeating things you've heard other people say because you don't actually know java?

The factory of factory crap was just fashionable nonsense that had nothing to do with java as a language itself. The XML API is like that, but personally I just wrote a hand full of wrapper functions for the common cases and just call those. Writing those wrappers took literally a minute or two. If I want to parse an XML file I just call XML.parse(String s)
Huh, we use threaded Python natively without any Java crap involved. Works fine.
The threads will run, but but only one at a time, which is fine if you just need to do file/network IO but not that helpful if you actually need to speed things up. If you have a lot of low-cohesion tasks (like serving web pages) then you can run a bunch of instances of the interpreter, but that won't help you if you need shared memory 'traditional' threading (as far as I know)

1) Build the simplest thing that works.
2) In the future, if you find it no longer works, goto 1.
Writing the simplest possible system, then writing the simplest possible patch to it is exactly how people end up with the convoluted monstrosities you're complaining about.
posted by delmoi at 8:25 AM on June 10, 2010


In Soviet Russia, OBJECT DEREFERENCES YOU!
posted by blue_beetle at 8:40 AM on June 10, 2010 [1 favorite]


this.thread.destroy()
posted by davejay at 9:34 AM on June 10, 2010 [1 favorite]


Writing the simplest possible system, then writing the simplest possible patch to it is exactly how people end up with the convoluted monstrosities you're complaining about.

No, DU has it right as far as I'm concerned. The convoluted monstrosities in question here are over-designed, overly-general systems that try to solve every possible future problem in the most efficient way, quite often never end up working at all, and if they do, they're unpleasant to use, and lead to ugly, unintuitive code, prone to failing in mysterious ways, and good luck getting it to compile on a first-gen toolchain for a new platform!

DU's method can lead to an entirely different kind of convoluted monstrosity, but only if you fail to execute step 2, due to denial, fear of the unknown, or being too schedule-bound year after year to do the necessary rewrites. But at least you've still had a working system all along.
posted by jeffj at 10:02 AM on June 10, 2010


I came here to make a hendecaton joke but it has pretty much already been made.
posted by Fezboy! at 10:18 AM on June 10, 2010


Except for C, of course, but how can you live without generics?

The co-pays are a little higher, but you get by, you know?
posted by backseatpilot at 10:48 AM on June 10, 2010 [1 favorite]


If I'm reading this correctly these are identical instances of the same object, in other words coded identically. To make it truly less than useless & move it into territory thats actually dangerous you'd need to make multiple implementations of the same object, perhaps selected by a random number generator. That way you'd never know if you're getting the better coded one or the one that leaks memory, handles errors poorly & breaks on bad input.
posted by scalefree at 11:14 AM on June 10, 2010 [1 favorite]


No, DU has it right as far as I'm concerned. The convoluted monstrosities in question here are over-designed, overly-general systems that try to solve every possible future problem in the most efficient way,
It depends on what you looking at. But there are definitely hacked together kludges upon kludges.

If you want to do it the "simplest possible way" you have to be willing to throw out your old code and replace it with something more general when you want to add stuff to it. An example might be, suppose you write the code to store your data in Json text files and you use the Json object model throughout all of your code instead of building your own object model and something that builds your model from the Json.

If you want to generalize later, to, say, using a relational database you could write a 'simple' system to convert data in the database to Json before feeding it into your program. But now you have a pretty convoluted system. There's no rational reason to convert relational data into Json and use a Json API to manipulate it. A future developer is going to pull their hair out.

On the other hand, if you're willing at that point to throw out the original system and build an object model and a Json and DB interface to that model it's OK. But like you said, there's time pressure, deadlines, etc.

Obviously it's always possible that you might guess wrong about what kind of flexibility you need, and adding too much generality ends up adding needless complexity. You need to find a balance. And frankly the idea that you need to do things "one way" is dumb. If you have a one off tool that you need for a specific purpose, then it makes sense to do it quickly. If you have a huge project that needs to be modified from time, it makes sense to try to keep things general.

Anyway, none of this has anything to do with Java specifically, it's applicable to any language.
posted by delmoi at 11:18 AM on June 10, 2010


If I'm reading this correctly these are identical instances of the same object, in other words coded identically. To make it truly less than useless & move it into territory thats actually dangerous you'd need to make multiple implementations of the same object, perhaps selected by a random number generator. That way you'd never know if you're getting the better coded one or the one that leaks memory, handles errors poorly & breaks on bad input.
Well, that's the thing. If you only have one implementation, then a programming mistake will make all instances crash. So what you do is write an interface specification, then hire a bunch of outsourced programmers from randomly selected countries to implement them. You pick an implementation at random, and that way just like genetic diversity helps populations your program will be less likely to crash!
posted by delmoi at 11:20 AM on June 10, 2010


You pick an implementation at random, and that way just like genetic diversity helps populations your program will be less likely to crash!

Less likely to crash per execution, yes. But all I have to do is run it multiple times to increase my odds of hitting one of the bad implementations. If you really wanted genetic diversity you'd choose between them at compile time, so each copy has a different set of routines that all conform to the same specifications.
posted by scalefree at 12:25 PM on June 10, 2010


There's no rational reason to convert relational data into Json and use a Json API to manipulate it. A future developer is going to pull their hair out.

Is it really any worse than converting relational data into your custom format to use your own custom API to manipulate it? Given that your custom API was built before you knew about these use cases, who is to say it is better suited to deal with them? Why not do that work when you know the actual requirements?

You need to find a balance. And frankly the idea that you need to do things "one way" is dumb.

Sure. But I've seen far more people (including myself) at the other end building a big generic library that will only ever serve one project before getting tossed. It seems better to build something useful and then abstract the parts you need for the next project, rather than start by worrying about the abstractions when you don't even know if the project is useful.
posted by Gary at 4:01 PM on June 10, 2010


Is it really any worse than converting relational data into your custom format to use your own custom API to manipulate it?

Um, yes?
posted by delmoi at 1:07 AM on June 12, 2010


I didn't mean you should leave it in Json. But abstracting the code later into a custom API that supports both methods is probably going to leave something better than hoping you made all the right choices abstracting it the first time.

Granted, experience plays a large role in this and if you've built 100 systems then you can probably make a good guess what to abstract away in the 101st. But if you are the doubleton guy, I'd rather you leave your data in a standard simple format like Json than try to help out and guess all future possibilities.
posted by Gary at 9:03 AM on June 12, 2010


The threads will run, but but only one at a time, which is fine if you just need to do file/network IO but not that helpful if you actually need to speed things up. If you have a lot of low-cohesion tasks (like serving web pages) then you can run a bunch of instances of the interpreter, but that won't help you if you need shared memory 'traditional' threading (as far as I know)

Err, yea. I talked to a co-worker about this and apparently we had long discussions about the global locking issue two years ago when we were evaluating languages for our test infrastructure. I really should try looking stuff up before I talk out of my arse on Metafilter.
posted by octothorpe at 8:58 AM on June 13, 2010


« Older Like a Mars Volta album that you can play to your...   |   Slicing Maestro Newer »


This thread has been archived and is closed to new comments