- 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
Very Adams-esque.
Admin
There are 3 types of developers, those who can count and those who can't.
Admin
s|Pair|Crowd|g
CAPTCHA: paste
Admin
plz tell me this is a joke.
Admin
That was redundant...
That was redundant...
Admin
Perfect! Now I know how to return results from:
Admin
Oh, i get it! The WTF is that it isn't immutable. :)
Admin
I'm struggling to imagine just how this was used. Maciek, if you are here, please provide us some examples.
Admin
But of course, you can retort "But you don't really have a pair, do you?".
Admin
Admin
You guys have no clue. This is a very elegant and useful structure. Not only can you now return arbitrary objects (you can even return more than one null, for example), it even supports nesting! You can easily build trees from pairs (aka "prees"), and by adding just one little method: Pair getRest(), you can emulate a cool variation of functional-style list programming - in Java! This amazing invention is the mother of all data structures! Can't you see this? Ignorant fools...
Admin
Best guess is that it originally returned 2 items, then someone needed an additional item, and rather than rename it correctly, or perhaps change to some array of args to make it generic, they just added another field. Lazy good-for-nothing ... (it's too early in the year for this)
Admin
A ternary pair tree? A tree-o-nulls? I love it! Actually, a proper pair-implementation could still provide the extra args
Admin
Its obviously the threesome class' public name.
Captcha stfu
...NO U
Admin
Even better, he has a
As for renaming them to reflect their usage and intention:
Admin
FWIW, the .NET framework provides this exact same object (albeit correctly named) as System.Web.UI.Triplet (alongside the equally useful System.Web.UI.Pair). Quite why they're buried in the System.Web.UI namespace is beyond me though.
Admin
Maybe 'Pair' is the plural usage and it's just a data structure to hold up to three pair...
getFirstPair()
getSecondPair()
getThirdPair()
etc.
I could see that being useful. Sort of.
Admin
Well, I guess you could get a partriage in a pair three.
Or perhaps this Au Pair is lookng for a Menage a Trios.
Admin
I almost sprayed tea all over my keyboard after reading that. I've learned my lesson - don't sip tea (or any liquid for that matter) while reading the daily WTF [captcha].
Admin
You know ...
That sounds awfully like my college teacher asking us to arrange teams consisting in "pairs of three".
Oh, and that was a Computer Science-related teacher... maybe he helped with this code?
Admin
He probably heard "me y mi compadre" somewhere and, not knowing spanish, spelt it phoenetically.
Admin
It was coded by the producer of Car Talk.
"Welcome back to the third half of Car Talk with us, Click and Clack ...."
Admin
So, who's on Second?
Admin
They are used for storing objects in the viewstate
Admin
No, Who's on first.
Admin
Guess: The guy who needed the Triplet was in the Web.UI team and wasn't allowed to modify any other namesapces. Either he'd go through a series
of meetings, at various levels of the .NET project managements, to approve a modification to the right namespace or do it in System.Web.UI and get it over with.
Admin
I think all they wanted is some kind of predicate : object1, operator, object2 ( like ("jim" "owns" "doggie") , ("doggie" "is a" "dog"), ... ), so they describe problems and solve them in a prolog-like approach. Or like RDF statements. But then they came with an awfully confusing naming convention, the mother of all WTFs ;-)
Admin
Why simply return a Collection instance when you can hard code a fixed number of fields into a badly named class! Brilliant.
Admin
You really have to wonder what their class that only deals with two variables is called.
Admin
My high school gym teacher used to say "line up in pairs of three", but stopped long before I arrived in his class. My uncles had seen to that. Years before, they had repeatedly infuriated him by getting their buddies to line up in groups of six when he'd say that.
He never did figure out (or admit to figuring out) why they were lining up in sixes, but at least he stopped saying "pairs of three". :p
He was also fond of saying, "If it fits the shoe, wear it." Interesting guy, but not for any intended reasons....
Admin
As someone who has a looming problem like this in code he's now responsible for, I can say with near certainty that this was caused by plain old scope creep. The clear answer is instead of naming classes things like FooPair, just start with FooNTuple and let the future take its inevitable course.
Admin
Wow. That's, like, an obfuscated WTF!
878470?
Admin
More generic is the opposite of what they should have done. I'd much rather have java.awt.Point and java.awt.Dimension than a single (theoretical) PairOfInts class. Writing small but meaningful struct-like classes for aggregate return values is trivial and the only reason not to do it is, as you said, laziness.
Admin
Depending on the type of collection class used, you may need to dynamically resize (or "grow") the collection. The nice part about the code snippet is that, if the number of objects is fixed, you will never need to grow a pair.
Admin
I bet it's "Singleton".
Admin
In keeping with the genital theme, my money's on "Unit."
Admin
That's not really Enterprisey. In our company, we've implemented a pair that is around 33.33% bigger than this one, and has double the size of standard, non-enterprisey pairs.
Admin
You mean "yo y mi compadre," don't you? But that's unpolite, when enumerating people, you are supposed to name yourself last, as in: "mi compadre y yo".
Back on topic, I've seen latex gloves coming in "pairs of three" so you had an extra one in case one broke in the middle of your dish washing. Maybe this was a glove factory stock system?
Admin
So the third glove had the thumb in the middle?
Admin
Except, according to the OP, this class is inspired by the STL pair class, which is also mutable (according to glibc's headers, anyway).
Admin
That must be for the parity information...
Admin
WTF?
Why is there a posting for a business development job in the Non-WTF job listings? Aren't these all supposed to be software development jobs?
"Senior Director Development, Select Service Hotels"
[CAPTCHA: wtf]
Indeed!
Admin
Wow... if only all languages had Tuple's, that could save a lot of time :)
p.s. captcha : quality
Admin
Ya'll caught me.
In the future, I promise to think about asking a native speaker before I butcher foreign phrases. :)
Admin
It must be a "baker's pair."
Admin
No, it has a recursive pair of thumbs so it can go both ways (also useful for the multitudes with two thumbs on one hand) ;)
Admin
Perhaps, like me, they just find the word "tuple" to be vaguely pornographic.
Kind of like "s'mores." *eeeeeeuuuugh*
Admin
I beg to differ. The existence of classes like awt.Point or Dimension are justified because they are entities which can (in a semantical sense) stand for themselves. A pair on the other hand is just a pair. Although you may represent a point by it, they are not the same. Thus, I don't think it has anything to do with laziness when avoiding classes for virtually everything. A helper class like a pair (or triple in that case?!) is quite useful. In fact I think you would be overdoing it if you would declare an own class every time you need to hold certain values which itself do not represent a notional entity. If I were to write a program with some sort of custom Point representation I would not of course keep handling pairs but I might define it with the help of such.
I keep my own java library with useful methods and classes and pair has to proofen to be one of the most usefuls ones. For some geometric algorithms I required to temporarily associate Points with an index. I think it would be inappropriate to especially define a IndexedPoint class for that. Instead I simply used a Pair<Integer,Point>. I think that is a good example of when utilizing such classes makes sense.
package util.misc;
public class Pair<T, E> {
private T t;
private E e;
public Pair() {
t = null;
e = null;
}
public Pair(T t, E e) {
this.t = t;
this.e = e;
}
public final E getSecond() {
return e;
}
public final void setFirst(E e) {
this.e = e;
}
public final T getFirst() {
return t;
}
public final void setSecond(T t) {
this.t = t;
}
public String toString() {
String s = "Pair(";
s += t + ", " + e + ")";
return s;
}
}
Admin
Uh... Any reason why you wouldn't use a HashMap for that?
Admin
Nope, it would have been just a "thumb"