• IA (unregistered)

    Even the compare is not needed. The "checked" is always true so it's enough to look at the "IsFlagged" itself. And it would be more readable too.

  • MaxiTB (unregistered)

    var isFlagged = FilterCheckBox.Checked; FilteredSortedItems = isFlagged ? CurrentItemList.Where(info => info.IsFlagged == isFlagged).ToList() : CurrentItemList.ToList();

    Smells like a serious case of over engineering or trying to write clean code without understand what clean code is all about :-)

  • Prime Mover (unregistered)

    I wonder whether a developer was bored one Friday afternoon? Or wanted to drag a job out a little longer so as not to be in the frame for another project for a while? Can't see how this sort of thing is not at least partly deliberate over-engineering for the sake of it.

  • Andrew (unregistered) in reply to Prime Mover

    The intern needed to do some CS homework, and accidentally committed it.

  • WTFGuy (unregistered)

    @MaxiTB ref

    var isFlagged = FilterCheckBox.Checked; FilteredSortedItems = isFlagged ? CurrentItemList.Where(info => info.IsFlagged == isFlagged).ToList() : CurrentItemList.ToList();

    I suspect that could be further simplified to

    FilteredSortedItems = FilterCheckBox.Checked ? CurrentItemList.Where(info => info.IsFlagged).ToList() : CurrentItemList.ToList();
    
  • (nodebb) in reply to Prime Mover

    The developer was paid by line of code.

  • jay (unregistered)

    "The developer was paid by line of code." I once had a job where management said they were going to start rating programmers by lines of code produced per day. And I thought, great! I can boost my productivity by that measure easily! No more "x=x+4". Instead I'll write "x=x+1" four times. And loops? No, just copy and paste the same code as many times as you need. I had lots of ideas like that. Sadly, the company never followed through on the policy.

  • jay (unregistered)

    I regularly see code that says,

    if <whatever condition> 
        flag=true
    else 
      flag=false"
    

    Umm, why not just "flag=<whatever condition>".

    Or the one that really drove me nuts:

    if flag1
      flag2 = true
    

    else flag2=false

    Let's take 4 lines of code to say flag2=flag1.

  • Wizofaus (unregistered) in reply to Andre Alexin

    Then why the K&R style braces?^

  • Barry Margolin (github)

    My guess is that the method was originally intended to be used more generically -- the name suggests that it's for turning the boolean into an array index. But those other users have gone away, and now we're just left with this WTF.

  • Barry Margolin (github)

    My guess is that the method was originally intended to be used more generically -- the name suggests that it's for turning the boolean into an array index. But those other users have gone away, and now we're just left with this WTF.

  • Argle (unregistered)

    return ArgleSeesAnotherMisuseOfBoolToday ? "Bang head here" : "Wait until tomorrow";

  • Twither (unregistered)

    For the love of-- just cut the ternary already.

    FilteredSortedItems = CurrentItemList.Where(info => info.IsFlagged || !FilterCheckBox.Checked).ToList();

  • (nodebb)

    There are places where equality comparison with booleans is strongly discouraged (possibly places with a strong fortran background), as you should be using logical operations (and, or, xor), which does have some appeal. This looks something like someone trying to get round a restriction like that.

    Addendum 2022-03-24 05:02: among other things, it stops people writing if <boolean> == false ...

  • james davis (unregistered)

    Crypto Recovery Services Crypto Recovery Services, Houston, TX. 1 talking about this. How to recover lost, stolen, hacked, forgotten and scammed crypto currencies from fraudulent investment platforms Website: www.cryptoreclaimfraud.com

  • Jim Jam (unregistered)

    I can imagine this method is used to find an index of some element whose position depends on whether or not the checkbox is on. Right now, it shifts on just one position, but this might be different in the past or mah change in the future. Should there be multiple elements displayed before the "Filter", the smart solution with Convert.ToInt would inevitably break.

    I do not argue that the original solution is terrible but it is not absolutely pointless.

Leave a comment on “Filter Your Index”

Log In or post as a guest

Replying to comment #:

« Return to Article