35
viking8
8y

Going through code left by a senior developer who quit.. Dated 2015..

public static T IfThenElse<T>(bool isTrue, T ifYes, T ifNo)
{
if(isTrue) { return ifNo ; }
else if(!isTrue) { return ifNo ;}
Debugger.Break();
throw new Exception("") ;
}
.....
There was a unit test for it well
....
............. Wow, just wow

Comments
  • 3
    So.... return ifNo; ?
  • 5
    I refuse to believe that.
  • 2
    So that's utterly stupid code, but was it actually called from anywhere else, or had they just accidentally left it in place? I'm trying to reason what would possess someone to write that.
  • 5
    That's a cry for help if I ever saw one.
  • 1
    @mclovinit oh no :) it's used several times for label messages ..

    I can't edit the rant to add screenshots, but it's used like this;

    SyncToggleLabel = IfThenElse(syncEnabled, "Sync Enabled", "Sync Disabled");
  • 0
    Its actually a quite clever lambda functional interface he made there you morons.
  • 0
    Rarely is "clever" supportable, which is clear from this rant.
  • 1
    It's C#. And it was returning false, the test succeeded because it was wrong too :P

    Nothing clever here at all, a simple ? would do the exact same thing
  • 0
    This construct is about as useless as a third trit if you get the joke.

    A base-three system is used in Islam to keep track of counting Tasbih to 99 or to 100 on a single hand for counting prayers (as alternative for the Misbaha).

    Also used in transistor logic and fast addition, none of which seems applicable to this use case. But would need to know more about the code to decide what could be done to make it more supportable.

    https://en.m.wikipedia.org/wiki/...
Add Comment