160

Immortalised this actual legacy code for our Senior Devs leaving present (we all inherited this) with his last task being to refactor it, may he never have to work with code like this again.

Comments
  • 11
    "may he never have to work with code like this again" that was my line you arse was it not enough to steal my internet points :/
  • 9
    If you are gonna write bad code at least make it work. Its only 8 possibilities to check for.
  • 14
    *ahem*

    public string YesConverter(string yes)
    {
    if ("yes" == yes.ToLowercase())
    return "yes";
    return "no";
    }
  • 6
    @filthyranter

    God I hope you haven't used the same approach that our legacy dev had done in any of your projects.

    bool yes;

    Solved.
  • 10
    @delegate212 This isn't even my final form:

    public string YesConverter(string yes)
    {
    yes = yes.Trim().ToLowerCase();
    if (yes.Contains("yes") return "yes";
    return "no";
    }

    Huehuehuehue
  • 3
    Seriously tho, before replacing it by boolean logic when the surrounding system isn't fixed yet, I'd first change it to my first comment.
  • 3
  • 2
    Ah, the good old yes converter!
  • 7
    this.YesConvert("Oui");
    this.YesConvert("Ja");
    this.YesConvert("Si");
  • 6
    Am I a noob or Did no one else notice that the function declaration name and invocation names do not match.
  • 1
    @aneesh I indeed didn't notice that
  • 2
    @filthyranter how about straight send it to server, let sql ignores the case 😼
  • 5
    @sunfishcc yes; DROP TABLE users;
  • 1
    @scor I'm just mentioning you so you can read about the YesConverter once the mentions start flowing again
Add Comment