- 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
Admin
I got this less-WTF but functionally equivalent code:
These multiple negates aren't restricted to computer science. I remember in biology that alcohol is an anti-diuretic hormone inhibitor - so what does it do? Baptists and Muslims had to really work it out, everyone else knew by first hand experience.
Admin
I know why he created this method; it is so that if the value of One ever changed, and he had to change all of those checks to Count >= 2 (or 3.34, or something) then he would have one (i.e. 1) place to change it. So, just in case he should make it more enterprisy and add an xml config to find out the number that he needs to check for, and the values to return:
Captcha: illum - 1) the lack of a unit of illumination
Admin
You're assuming they're using version 3.0 or newer of the framework. We're still using 2.0 at work; I would love the ability to use extension methods.
Hell we still have POS code written in 1.1. Kill me?
Of course, I'm assuming it's C#, it certainly looks like it.
Admin
You are of course technically correct, the very best kind of correct :) .NET would almost certainly implement it as a property.
Although this does mean you'd just have an automatically generated method in the class, with the signature "private bool get_IsEmpty()". I do love syntactic sugar though :)
Admin
Ok, just got a few free minutes:
Admin
Actually, the code does work as advertised. It's ridiculous code and the author was probably typing with his/her tongue, but it does do what it says it will do.
Admin
So, I nearly peed myself. Thanks! And now I am off writing my next app with ONLY recursion and exceptions. We don't need no stinkin "if"; keep your "while" to yourself, and those new-fangled loops? Shocking, just shocking.
Admin
Maybe he wasn't allowed access to a keyboard and had to dictate his code to a blind sea slug?
Admin
Admin
... but what when patties = -2?
Admin
Shouldn't this be an extension method?
Admin
Here's my attempt at a Python list with float indexes. If the index given is not an integer, does a weighted average of the adjoining items.
Admin
return true;
and get the same result.
Admin
This is so south park. Thx, it made me smile.
Admin
Or maybe:
Ahh f**k it!
Admin
What, exactly, does it say it will do?
"Is" - OK, this says it's probably checking whether some condition is true
"List" - Ah, it's checking something about a List. Except that this function name seems to be CamelCased, so I really need to be examining "Listconnt". So the function is checking something about a "Listconnt". Never heard of one of those. Lemme go check Google ... OK, there's a bunch of Asian-language pages there, with the first one showing < t clas"listConnt et">. Ah, OK, so this function is checking some property of a < t clas"listConnt et">, or possibly the < t clas"listConnt et"> property of some object. Got it.
"Smalle" - again, never heard of this, so I'll go back to Google. AH! It's referring to Smalle lab!
"Tha" - once again, never heard of this. But tha.com is the Tennessee Hospital Association.
"One" - OK, that's clearly representing the number 1. Maybe it means "first"?
OK, I think I've figured this out. IsListconntSmalleThaOne should determine whether the '< t clas"listConnt et">' property of Smalle lab is pointing to the first Tennessee Hospital Association.
So no, it doesn't work as advertised.
Admin
Admin
It can have a count of 0.5 if you use fuzzy integers.
Admin
I've actually seen that done.
Admin
I bet your coworkers love you. Particularly during requirements review.
Admin
This is quite inane with strings, but potentially quite sensible with numeric types, provided that you give it a more sensible name than 'XXXList'. What you're really making is an interpolator class, which is useful. (You can even do it with arbitrary, potentially negative indexes. Crazy list, useful interpolaton. Oh, perspective.)
eg. template<typename T> class Interpolator { private: List<Point<T,T>> known;
public: Interpolator(); void setKnown(Point<T,T> point); T interpolate(T independent) const; T operator[](T independent) const { return interpolate(independent); } };
The only arguable evil is the questionable operator overload ;)
Admin
Would you guys please stop picking on my code? I mean, all I'm trying to do is find out if my friend, Listconnt Smalle, is Tha One. Don't tell me I can't use ebonics in my code!
Admin
The hormone is called "anti-diuretic hormone". There is not such thing as the "diuretic hormone", hence the double negation is absolutely correct in that case...
CAPTCHA: inhibeo (no, I'm not joking)
Admin
public bool IsListconntSmalleThaOne(IList<IContact> listOfResults) { if (listOfResults != null) { return !Convert.ToBoolean(listOfResults.Count); } return true; }
Admin
Admin
The usage would look like this:
Admin
Admin
I'm fairly sure it means exactly what I think it does, actually: Characterized by clear, precise expression in few words; concise and terse.
My example used no terms than were necessary to fit the criteria, hence succinct. I could have written it a shorter manner, but it would have ceased to be clear, concise and terse.
Admin
public class doubleIndexedList<T extends Number> implements Collection{
private ArrayList<T> positiveIndices; private ArrayList<T> negativeIndices;
private double threshold; //threshold for floating-point equality comparisons
public static double DEFAULT_THRESHOLD = 0.00001d;
public doubleIndexedList<T extends Number>(){ threshold = DEFAULT_THRESHOLD; positiveIndices = new ArrayList<T>(); negativeIndices = new ArrayList<T>(); }
public doubleIndexedList<T extends Number>(double threshold){ this.threshold = threshold; positiveIndices = new ArrayList<T>(); negativeIndices = new ArrayList<T>(); }
public T get(double index){
if(index > 0){ if(index - Math.floor(index) < threshold){ //Whole number index return positiveIndices.get(Math.floor(index)) }else{ //Fractional index double nearest = Math.floor(index); return positiveIndices.get(nearest)(index-nearest); } }else{ index=-1; //Fix sign if(index - Math.ceil(index) < threshold){ //Whole number index return negativeIndices.get(Math.ceil(index)) }else{ //Fractional index double nearest = Math.ceil(index); return negativeIndices.get(nearest)*(index-nearest); } } } . . .
}
Admin
Admin
Pin it?
Admin
Correction:
(new SomeObject().IsListconntSmalleThaOne(list))
Admin
Was it the person who coded it or the manager that lets staff get away with it? Or even the interviewer come to think of it.
personally I write some shite code, but if anyone else was using it, I would follow a guide (any company developing software should have a guide on naming conventions and methods).
So shame on you for employing him and then blaming him for being crap.
Admin
You might have to settle for 3 back points.
Admin
Hmm, a double indexed list... That indeed sounds like a challenge.
Should it be an array, vector, linked list, hash set, rb set, or anything else?
I can probably make up something generic enough that it could officially be called a "double indexed list".
FYI, I already made a list with complex indexes in the form of a + bi with a, b \in \mathbb{N} ;)
Admin
I think you meant "rAndoM caPiTAlizAtION".
Admin
Admin
Vectors, man. Vectors! It's still a double cheeseburger, just going the other direction.
Admin
Admin
Lucky you!
Our coding standard forbids the ternary operator ?:
Admin
The compiler not knowing the difference between an integer and a boolean maybe just a minor insanity, but it leads to plenty of larger ones. Yoda conditions, separate "logical" and "bitwise" versions of all the boolean operators, etc...
Admin
Spelling errors aside, wouldn't this make sense if it was being used in a delegate?
Admin
I don't like it when my cheeseburger goes the other direction...
Admin
How can it possibly be "far more succinct" (i.e., concise and/or terse) than the physically shorter "(!myList.Count)"? That's basically the definition of "terse," isn't it: short? So you're saying, "This version is shorter than that version, even though it's longer." Wut?
Admin
How can it possibly be "far more succinct" (i.e., concise and/or terse) than the physically shorter "(!myList.Count)"? That's basically the definition of "terse," isn't it: short? So you're saying, "This version is shorter than that version, even though it's longer." Wut?
Admin
I am not sure I understand your definition of succinct... can you expand on it?
Admin
The real WTF, as usual, is that only one person recognizes that there may be a perfectly valid reason for doing something, while everyone else is bickering about a side topic (in this case, the definition of "succinct").
Admin
This isn't even guaranteed to halt if you are programming in Haskell, since your list could be infinite. But then Haskell isn't a sane language anyway.
Admin
I meant the (!myList.Count) thing, of course.
Forum 1 x 0 Me