-Поиск по дневнику

Поиск сообщений в rss_thedaily_wtf

 -Подписка по e-mail

 

 -Постоянные читатели

 -Статистика

Статистика LiveInternet.ru: показано количество хитов и посетителей
Создан: 06.04.2008
Записей:
Комментариев:
Написано: 0


CodeSOD: Switched Over

Четверг, 01 Июня 2017 г. 13:30 + в цитатник

Twelve years ago, a company decided they needed a website. They didnt have any web developers, and they didnt want to hire any, so they threw a PHP manual at the new hire who happened to be good with computers, and called it a day.

Ms. Good With Computers actually learned something from the experience, and moved on to a lucrative career in web development. Unfortunately, she left behind the code she learned by doing, and now Bert has been brought in to clean up the code.

Take this block, which translates an airport code into a location name…

    switch ($v) {
        case "EIN": $ori = "Eindhoven";
            break;
        case "EIN": $ori = "Eindhoven";
            break;
        case "EIN": $ori = "Eindhoven";
            break;
        case "EIN": $ori = "Eindhoven";
            break;
        case "EIN": $ori = "Eindhoven";
            break;
        case "EIN": $ori = "Eindhoven";
            break;
        default: break;
    }

    switch ($b) {
        case "WRO": $des = "Wroclaw";
            break;
        case "WRO": $des = "Wroclaw";
            break;
        case "WRO": $des = "Wroclaw";
            break;
        case "WRO": $des = "Wroclaw";
            break;
        case "WRO": $des = "Wroclaw";
            break;
        case "WRO": $des = "Wroclaw";
            break;
        case "WRO": $des = "Wroclaw";
            break;
        case "WRO": $des = "Wroclaw";
            break;
        case "WRO": $des = "Wroclaw";
            break;
        case "WRO": $des = "Wroclaw";
            break;
        case "WRO": $des = "Wroclaw";
            break;
        case "WRO": $des = "Wroclaw";
            break;
        default: break;
    }

Theres hundreds of lines of this, following the same pattern- one switch block with the same condition repeated many times for each possible airport code. These blocks dont exist in a function, either- theyre slapped right into the global namespace.

[Advertisement] Otter enables DevOps best practices by providing a visual, dynamic, and intuitive UI that shows, at-a-glance, the configuration state of all your servers. Find out more and download today!

http://thedailywtf.com/articles/switched-over

Метки:  

 

Добавить комментарий:
Текст комментария: смайлики

Проверка орфографии: (найти ошибки)

Прикрепить картинку:

 Переводить URL в ссылку
 Подписаться на комментарии
 Подписать картинку