162

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
  • 12
    "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.
  • 13
    *ahem*

    public string YesConverter(string yes)
    {
    if ("yes" == yes.ToLowercase())
    return "yes";
    return "no";
    }
  • 5
    @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.
  • 8
    @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
  • 2
    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.
  • 2
  • 1
    Ah, the good old yes converter!
  • 4
    this.YesConvert("Oui");
    this.YesConvert("Ja");
    this.YesConvert("Si");
  • 5
    Am I a noob or Did no one else notice that the function declaration name and invocation names do not match.
  • 0
    @aneesh I indeed didn't notice that
  • 1
    @filthyranter how about straight send it to server, let sql ignores the case 😼
  • 3
    @sunfishcc yes; DROP TABLE users;
Add Comment