• That Guy (unregistered)

    IFRisTP0zTer();

  • anonymous coward (unregistered)

    Wow. That is insane.

  • 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!

  • (cs)

    My god. Its full of typing.

  • (cs)

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

  • (cs) in reply to frits
    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).

  • anonymous coward (unregistered) in reply to frits
    frits:
    Did anybody notice that (myList.Count < 1) is significantly shorter than IsListconntSmalleThaOne(myList) ?

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

  • littlebobbytables (unregistered)

    It's still better than sourcesafe.

  • pbean (unregistered)
    public bool IsListconntSmalleThaOne(IList<IContact> listOfResults)
    {
    try
      {
        listOfResults[1];
        return false;
      }
      catch(IndexOutOfRangeException e)
      {
        return true;
      }
    }
    
  • Dude (unregistered) in reply to anonymous coward

    if len(list) < 1: profit();

  • NoAstronomer (unregistered)

    At least it's not VB.

    /duck /run

  • (cs)

    I don't know, but it might not be thread safe

  • (cs) in reply to That Guy

    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.

  • Steve The Cynic (unregistered) in reply to littlebobbytables
    littlebobbytables:
    It's still better than sourcesafe.
    WIN!
  • 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!

  • (cs) in reply to NoAstronomer
    NoAstronomer:
    At least it's not VB.

    /duck /run

    Everyone loves a holy war. Kill the beast!!

  • jhawk28 (unregistered)

    Its missing the unit tests...

  • 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?? } }

  • dignissim (unregistered) in reply to anonymous coward

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

  • pbean (unregistered) in reply to 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?? } }

  • dignissim (unregistered) in reply to anonymous coward
    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?

  • bl@h (unregistered)

    Obviously meant for embedded systems.

  • (cs)

    And he doesn't even guard for null

  • 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;
        }
    }
    
  • Nahgoe (unregistered) in reply to tiller
    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!!
  • (cs) in reply to dignissim
    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.

  • Nick (unregistered) in reply to anonymous coward
    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.

  • AdamK (unregistered)

    What about the obvious FILENOTFOUD?

  • (cs)

    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.

  • Anon (unregistered) in reply to Nahgoe
    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!

  • Nick (unregistered) in reply to Knux2
    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;
        }
    }
    
  • wtf (unregistered) in reply to toth
    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.

  • 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.

  • SR (unregistered) in reply to pbean
    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).

  • (cs) in reply to tiller
    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.

  • (cs)

    Don't we have webservices nowadays to check for list sizes?

  • SR (unregistered) in reply to Anonymous
    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).

  • pbean (unregistered) in reply to toth
    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
    
  • (cs)

    Sometimes it's better to write some more code just for the sake of code cleanliness, but this... this is just wrong.

  • (cs) in reply to toth
    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));

  • wtf (unregistered) in reply to Anonymous
    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; } }

  • timo (unregistered) in reply to Stevil
    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.

  • Dom (unregistered)

    The real WTF is that this is not an extension method.

  • (cs) in reply to wtf
    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.

  • (cs) in reply to pbean
    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));
    }
    
    
  • 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?"

  • Your Name (unregistered) in reply to pbean
    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!

  • Someone who can't be bothered to login from work (unregistered) in reply to tiller
    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.

  • (cs) in reply to pbean
    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

  • Someone who can't be bothered to login from work (unregistered) in reply to toth
    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.

Leave a comment on “IsListconntSmalleThaOne”

Log In or post as a guest

Replying to comment #:

« Return to Article