Comment On IsListconntSmalleThaOne

If Peter Moberg were to give a single criticism of his colleague's work, it would be that it represents a complete and total misunderstanding of the principles of software development. [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Re: IsListconntSmalleThaOne

2010-06-09 09:01 • by That Guy (unregistered)
IFRisTP0zTer();

Re: IsListconntSmalleThaOne

2010-06-09 09:02 • by anonymous coward (unregistered)
Wow. That is insane.

Re: IsListconntSmalleThaOne

2010-06-09 09:05 • by SR (unregistered)
I love it. And you know if he came across you checking >=1 in, you know, the sane way; he'd really get the hump!

Re: IsListconntSmalleThaOne

2010-06-09 09:05 • by Raedwald
My god. Its full of typing.

Re: IsListconntSmalleThaOne

2010-06-09 09:06 • by frits
Did anybody notice that (myList.Count < 1) is significantly shorter than IsListconntSmalleThaOne(myList) ?

Re: IsListconntSmalleThaOne

2010-06-09 09:08 • by tiller
311064 in reply to 311063
frits:
Did anybody notice that (myList.Count < 1) is significantly shorter than IsListconntSmalleThaOne(myList) ?


Yes but in this case, using isEmpty() is better. (I asume there is an isEmpty method).

Re: IsListconntSmalleThaOne

2010-06-09 09:09 • by anonymous coward (unregistered)
311065 in reply to 311063
frits:
Did anybody notice that (myList.Count < 1) is significantly shorter than IsListconntSmalleThaOne(myList) ?


(!myList.Count) should do the job, assuming a sane language.

Re: IsListconntSmalleThaOne

2010-06-09 09:12 • by littlebobbytables (unregistered)
It's still better than sourcesafe.

Re: IsListconntSmalleThaOne

2010-06-09 09:13 • by pbean (unregistered)

public bool IsListconntSmalleThaOne(IList<IContact> listOfResults)
{
try
{
listOfResults[1];
return false;
}
catch(IndexOutOfRangeException e)
{
return true;
}
}

Re: IsListconntSmalleThaOne

2010-06-09 09:13 • by Dude (unregistered)
311068 in reply to 311065
if len(list) < 1:
profit();

Re: IsListconntSmalleThaOne

2010-06-09 09:14 • by NoAstronomer (unregistered)
At least it's not VB.

/duck
/run

Re: IsListconntSmalleThaOne

2010-06-09 09:15 • by lazloman
I don't know, but it might not be thread safe

Re: IsListconntSmalleThaOne

2010-06-09 09:16 • by Smitty
311071 in reply to 311058
I see this kind of bullshit fairly regularly at my current job. Inane functions with misspelled words, random missing letters and my personal favorite, random Capitalization.

Re: IsListconntSmalleThaOne

2010-06-09 09:17 • by Steve The Cynic (unregistered)
311072 in reply to 311066
littlebobbytables:
It's still better than sourcesafe.

WIN!

Re: IsListconntSmalleThaOne

2010-06-09 09:17 • by Stevil (unregistered)
Our work is done on an inhouse framework (for better or worse) and has some nice simple functionality exposed to the developer, including a validity check method. For aggregated classes you just call it on all child classes and bingo, right...
Not if you are our italian subcontractor:

bool result = (CheckValidity() != false) ? false : result;

yes, a doubly inverted comparitive self assignment, molto bene!

Re: IsListconntSmalleThaOne

2010-06-09 09:17 • by Smitty
311074 in reply to 311069
NoAstronomer:
At least it's not VB.

/duck
/run


Everyone loves a holy war. Kill the beast!!

Re: IsListconntSmalleThaOne

2010-06-09 09:18 • by jhawk28 (unregistered)
Its missing the unit tests...

Re: IsListconntSmalleThaOne

2010-06-09 09:18 • by pbean (unregistered)
public bool IsListconntSmalleThaOne(IList<IContact> listOfResults)

{

int count = 0;
foreach (IContact contact in listOfResults)
{
count = count + 1;
}

if (count >= 1)
{
return 1 != 0; // I don't trust "false"
}
else
{
return 1 == 1; // is "true" really true??
}
}

Re: IsListconntSmalleThaOne

2010-06-09 09:18 • by dignissim (unregistered)
311077 in reply to 311065
What sane language could allow mixing of boolean and integral values?

Re: IsListconntSmalleThaOne

2010-06-09 09:19 • by pbean (unregistered)
311078 in reply to 311076
Oops I forgot the code tags. Fixed :)
pbean:
public bool IsListconntSmalleThaOne(IList<IContact> listOfResults)

{
int count = 0;
foreach (IContact contact in listOfResults)
{
count = count + 1;
}

if (count >= 1)
{
return 1 != 0; // I don't trust "false"
}
else
{
return 1 == 1; // is "true" really true??
}
}

Re: IsListconntSmalleThaOne

2010-06-09 09:20 • by dignissim (unregistered)
311079 in reply to 311065
anonymous coward:
frits:
Did anybody notice that (myList.Count < 1) is significantly shorter than IsListconntSmalleThaOne(myList) ?


(!myList.Count) should do the job, assuming a sane language.


What sane language could allow mixing of boolean and integral values?

Re: IsListconntSmalleThaOne

2010-06-09 09:27 • by bl@h (unregistered)
Obviously meant for embedded systems.

Re: IsListconntSmalleThaOne

2010-06-09 09:28 • by huai
And he doesn't even guard for null

Re: IsListconntSmalleThaOne

2010-06-09 09:28 • by Knux2 (unregistered)

final static String TCAR = "t";
final static String RCAR = "r";
final static String UCAR = "u";
final static String ECAR = "e";

public boolean isFlse (boolean bolean) {
if (bolean.toString().equals(TCAR + RCAR + UCAR + ECAR) {
return false;
}else{
return true;
}
}

Re: IsListconntSmalleThaOne

2010-06-09 09:29 • by Nahgoe (unregistered)
311083 in reply to 311064
tiller:

frits:

Did anybody notice that (myList.Count < 1) is significantly shorter than IsListconntSmalleThaOne(myList) ?

Yes but in this case, using isEmpty() is better. (I asume there is an isEmpty method).

You are also assuming that myList.Count is never negative!!

Re: IsListconntSmalleThaOne

2010-06-09 09:30 • by toth
311084 in reply to 311079
dignissim:
anonymous coward:
frits:
Did anybody notice that (myList.Count < 1) is significantly shorter than IsListconntSmalleThaOne(myList) ?


(!myList.Count) should do the job, assuming a sane language.


What sane language could allow mixing of boolean and integral values?


PHP or Perl

Oh, sane? None.

Re: IsListconntSmalleThaOne

2010-06-09 09:30 • by Nick (unregistered)
311085 in reply to 311065
anonymous coward:
frits:
Did anybody notice that (myList.Count < 1) is significantly shorter than IsListconntSmalleThaOne(myList) ?


(!myList.Count) should do the job, assuming a sane language.


That's only if you want to look 1337 by showing off your ability to treat integers as booleans. The rest of us would just use a form of !myList.isEmpty(), which is much more clear and, depending on the internal implementation of myList, may well get better performance.

Re: IsListconntSmalleThaOne

2010-06-09 09:31 • by AdamK (unregistered)
What about the obvious FILENOTFOUD?

Re: IsListconntSmalleThaOne

2010-06-09 09:33 • by toth
myList.Count == 0

OTFY

Unless, of course, you're dealing with weird, unnatural, abomination-before-God data structures that allow lists with negative or non-integral numbers of elements.

I want to see a list whose count is 0.5.

Re: IsListconntSmalleThaOne

2010-06-09 09:34 • by Anon (unregistered)
311088 in reply to 311083
Nahgoe:
tiller:

frits:

Did anybody notice that (myList.Count < 1) is significantly shorter than IsListconntSmalleThaOne(myList) ?

Yes but in this case, using isEmpty() is better. (I asume there is an isEmpty method).

You are also assuming that myList.Count is never negative!!


Exactly the point I was going to make. It could be a list of antiIContacts!

Re: IsListconntSmalleThaOne

2010-06-09 09:37 • by Nick (unregistered)
311089 in reply to 311082
Knux2:

final static String TCAR = "t";
final static String RCAR = "r";
final static String UCAR = "u";
final static String ECAR = "e";

public boolean isFlse (boolean bolean) {
if (bolean.toString().equals(TCAR + RCAR + UCAR + ECAR) {
return false;
}else{
return true;
}
}

Don't forget to handle case sensitivity.

final static String TCAR = "t";
final static String RCAR = "r";
final static String UCAR = "u";
final static String ECAR = "e";
final static String TCARCAP = "T";
final static String RCARCAP = "R";
final static String UCARCAP = "U";
final static String ECARCAP = "E";

public boolean isFlse (boolean bolean) {
if (bolean.toString().equals(TCAR + RCAR + UCAR + ECAR) {
return false;
}else if(bolean.toString().equals(bolean.toString().equals(TCARCAP + RCARCAP + UCARCAP + ECARCAP){
return false;
}
}else{
return true;
}
}

Re: IsListconntSmalleThaOne

2010-06-09 09:38 • by wtf (unregistered)
311090 in reply to 311087
toth:
myList.Count == 0

OTFY

Unless, of course, you're dealing with weird, unnatural, abomination-before-God data structures that allow lists with negative or non-integral numbers of elements.

I want to see a list whose count is 0.5.


Obviously representing one potential contact.
0.3 for a lead.
0.9 for that chick you ALMOST got digits from.

Re: IsListconntSmalleThaOne

2010-06-09 09:40 • by Anonymous (unregistered)
Oh my God that hurts. This is exactly the sort of shoddy coding that pisses me off the most. Atrocious spelling, useless method name, pointless functionality and it doesn't even work as advertised. But what really compounds the WTF is that this is so damn simple. When you screw up this badly doing something this simple, it's time to seriously consider whether software development is your calling in life. Note to the submitter, maybe you should leave a McDonalds job application form on his desk, see if he gets the hint.

Re: IsListconntSmalleThaOne

2010-06-09 09:41 • by SR (unregistered)
311093 in reply to 311078
pbean:
Oops I forgot the code tags. Fixed :)
pbean:
public bool IsListconntSmalleThaOne(IList<IContact> listOfResults)

{
int count = 0;
foreach (IContact contact in listOfResults)
{
count = count + 1;
}

if (count >= 1)
{
return 1 != 0; // I don't trust "false"
}
else
{
return 1 == 1; // is "true" really true??
}
}



Thanks. That makes it so much more readable (saner, too).

Re: IsListconntSmalleThaOne

2010-06-09 09:42 • by Satanicpuppy
311094 in reply to 311064
tiller:
frits:
Did anybody notice that (myList.Count < 1) is significantly shorter than IsListconntSmalleThaOne(myList) ?


Yes but in this case, using isEmpty() is better. (I asume there is an isEmpty method).


Pssh. Unlike the subby, you're not accounting for the case where there is a negative number of elements in the list.

Re: IsListconntSmalleThaOne

2010-06-09 09:42 • by Quicksilver
Don't we have webservices nowadays to check for list sizes?

Re: IsListconntSmalleThaOne

2010-06-09 09:43 • by SR (unregistered)
311096 in reply to 311092
Anonymous:
Note to the submitter, maybe you should leave a McDonalds job application form on his desk, see if he gets the hint.


Your ideas intrigue me and I would like to subscribe to your newsletter.

CAPTCHA: conventio (a convention followed by this story's coder).

Re: IsListconntSmalleThaOne

2010-06-09 09:44 • by pbean (unregistered)
311097 in reply to 311087
toth:
myList.Count == 0

OTFY

Unless, of course, you're dealing with weird, unnatural, abomination-before-God data structures that allow lists with negative or non-integral numbers of elements.

I want to see a list whose count is 0.5.


Kudos to the first to implement a TruncatedList collection class where you can index with floats and it somehow cuts the elements in pieces

Examples:

Strings:
0: Test
1: Truncated
2: List

Strings[0.5] = "Te"
Strings[1.22] = "Tr"

Integers:
0: 84
1: 1337
2: 2147483647

Integers[0.5] = 42
Integers[1.7] = 935.9

Re: IsListconntSmalleThaOne

2010-06-09 09:45 • by Kiss me I'm Polish
Sometimes it's better to write some more code just for the sake of code cleanliness, but this... this is just wrong.

Re: IsListconntSmalleThaOne

2010-06-09 09:45 • by snoofle
311099 in reply to 311087
toth:
myList.Count == 0

OTFY

Unless, of course, you're dealing with weird, unnatural, abomination-before-God data structures that allow lists with negative or non-integral numbers of elements.

I want to see a list whose count is 0.5.

list.get(Math.sqrt(-1.23456));

Re: IsListconntSmalleThaOne

2010-06-09 09:48 • by wtf (unregistered)
311100 in reply to 311092
Anonymous:
Oh my God that hurts. This is exactly the sort of shoddy coding that pisses me off the most. Atrocious spelling, useless method name, pointless functionality and it doesn't even work as advertised. But what really compounds the WTF is that this is so damn simple. When you screw up this badly doing something this simple, it's time to seriously consider whether software development is your calling in life. Note to the submitter, maybe you should leave a McDonalds job application form on his desk, see if he gets the hint.


public boolean isDoubleCheeseBruger(int patties)
{
if (patties * patties == 4)
return true;
else return false;
}
}

Re: IsListconntSmalleThaOne

2010-06-09 09:56 • by timo (unregistered)
311101 in reply to 311073
Stevil:
Not if you are our italian subcontractor:

bool result = (CheckValidity() != false) ? false : result;

yes, a doubly inverted comparitive self assignment, molto bene!


It makes perfectly sense, since in Italian double negation, well, negates.
I am Italian, anyway: I have not said nothing.

Re: IsListconntSmalleThaOne

2010-06-09 10:00 • by Dom (unregistered)
The real WTF is that this is not an extension method.

Re: IsListconntSmalleThaOne

2010-06-09 10:00 • by RogerC
311103 in reply to 311100
wtf:
Anonymous:
Oh my God that hurts. This is exactly the sort of shoddy coding that pisses me off the most. Atrocious spelling, useless method name, pointless functionality and it doesn't even work as advertised. But what really compounds the WTF is that this is so damn simple. When you screw up this badly doing something this simple, it's time to seriously consider whether software development is your calling in life. Note to the submitter, maybe you should leave a McDonalds job application form on his desk, see if he gets the hint.


public boolean isDoubleCheeseBruger(int patties)
{
if (patties * patties == 4)
return true;
else return false;
}
}


Wonderful! You give me two patties and I will then inform you that I've handed you a double cheesebruger. Win-win.

Re: IsListconntSmalleThaOne

2010-06-09 10:02 • by snoofle
311104 in reply to 311097
pbean:
toth:
myList.Count == 0

OTFY

Unless, of course, you're dealing with weird, unnatural, abomination-before-God data structures that allow lists with negative or non-integral numbers of elements.

I want to see a list whose count is 0.5.


Kudos to the first to implement a TruncatedList collection class where you can index with floats and it somehow cuts the elements in pieces

Examples:

Strings:
0: Test
1: Truncated
2: List

Strings[0.5] = "Te"
Strings[1.22] = "Tr"

Integers:
0: 84
1: 1337
2: 2147483647

Integers[0.5] = 42
Integers[1.7] = 935.9





Sorry, no time to play with strings, but for integers:


class FloatingIntArray {
private List<Integer> data = new ArrayList<Integer>();
public void add(Integer val) {
data.add(val);
}
public double get(double index) {
int signMultiplier = index >= 0.0 ? 1 : -1;
index = Math.abs(index);
int arrayIndex = (int) Math.floor(index);
if (arrayIndex >= data.size()) {
throw new IllegalArgumentException("Index: "+index+" is out of range");
}
double origValue = data.get(arrayIndex);
double fraction = index - arrayIndex;
return signMultiplier * origValue * fraction;
}
}
public TestBed() {
FloatingIntArray fia = new FloatingIntArray();
fia.add(84);
fia.add(1337);
fia.add(2147483647);
System.out.println("fia.get(0.5) = "+fia.get(0.5));
System.out.println("fia.get(1.7) = "+fia.get(1.7));
System.out.println("fia.get(-0.5) = "+fia.get(-0.5));
System.out.println("fia.get(-1.7) = "+fia.get(-1.7));
}

Re: IsListconntSmalleThaOne

2010-06-09 10:05 • by Drew (unregistered)
Clearly this person was getting paid by the line and was interested in creating a code-base which engendered long term maintenance to ensure job security.

Always ask yourself: "Is this a WTF or am I just missing the intent?"

Re: IsListconntSmalleThaOne

2010-06-09 10:08 • by Your Name (unregistered)
311106 in reply to 311097
pbean:
Strings:

0: Test
1: Truncated
2: List

Strings[0.5] = "Te"
Strings[1.22] = "Tr"


Yeah, THAT makes sense!

Strings[0.25] = "T"
Strings[0.5] = "Te"
Strings[0.75] = "Tes"
Strings[1] = "Truncated"

Exactly what I'd have expected!

Re: IsListconntSmalleThaOne

2010-06-09 10:11 • by Someone who can't be bothered to login from work (unregistered)
311107 in reply to 311064
tiller:
frits:
Did anybody notice that (myList.Count < 1) is significantly shorter than IsListconntSmalleThaOne(myList) ?


Yes but in this case, using isEmpty() is better. (I asume there is an isEmpty method).


There isn't. And it would be IsEmpty() if there were.

Re: IsListconntSmalleThaOne

2010-06-09 10:17 • by RobFreundlich
311108 in reply to 311097
pbean:
toth:
I want to see a list whose count is 0.5.


Death to the first to implement a TruncatedList collection class where you can index with floats and it somehow cuts the elements in pieces


FTFY

Re: IsListconntSmalleThaOne

2010-06-09 10:21 • by Someone who can't be bothered to login from work (unregistered)
311109 in reply to 311084
toth:
dignissim:
anonymous coward:
frits:
Did anybody notice that (myList.Count < 1) is significantly shorter than IsListconntSmalleThaOne(myList) ?


(!myList.Count) should do the job, assuming a sane language.


What sane language could allow mixing of boolean and integral values?


PHP or Perl

Oh, sane? None.


C and C++ will both accept it too; as boolean values are simply integers, where 0 is false and any other value is true.

I personally don't consider it an insanity of the language, more a laziness of the people who can't be bothered to actually state what they're doing in their operation. Just because a language lets you do something doesn't mean you should.

"if (!myList.Count)" and "if (myList.Count == 0)" are functionally equivalent. The latter, however, is far more succinct, even if more verbose.
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Add Comment