Dave G. writes, "I stumbled across this fairly innocent-looking line while implementing some new features:"

int _applicationId = SetApplicationId();

"My curiosity got the better of me, and I went to the definition of the SetApplicationId() method."

private int SetApplicationId()
{
    switch (ApplicationUserInfo.Current.ApplicationType.ToString())
    {
        case "Stradegy2": return Convert.ToInt32(ApplicationTypeEnum.Stradegy2);
        case "AdDetector": return Convert.ToInt32(ApplicationTypeEnum.AdDetector);
        case "MagAdvisor": return Convert.ToInt32(ApplicationTypeEnum.MagAdvisor);
        case "AdDetectorAlerts": return Convert.ToInt32(ApplicationTypeEnum.AdDetectorAlerts);
        case "MarketAdvisorAdTel": return Convert.ToInt32(ApplicationTypeEnum.MarketAdvisorAdTel);
        case "NewspaperAdvisor": return Convert.ToInt32(ApplicationTypeEnum.NewspaperAdvisor);
        case "MarketAdvisorMarketSpender": return Convert.ToInt32(ApplicationTypeEnum.MarketAdvisorMarketSpender);
        case "StradegyOnline": return Convert.ToInt32(ApplicationTypeEnum.StradegyOnline);
        case "AdSpender": return Convert.ToInt32(ApplicationTypeEnum.AdSpender);
        case "Evaliant": return Convert.ToInt32(ApplicationTypeEnum.Evaliant);
        case "eBooks": return Convert.ToInt32(ApplicationTypeEnum.eBooks);
        case "FrenchAdex": return Convert.ToInt32(ApplicationTypeEnum.FrenchAdex);

    }
    return 0;
}

How many WTF's do you spot? Dave counted at least four. Bonus points for replacing this gem with one line, and note that the code is C# and ApplicationType is of type ApplicationTypeEnum.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!