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

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

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

 

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

 -Статистика

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


CodeSOD: Accurate Comments

Четверг, 12 Февраля 2015 г. 15:00 + в цитатник

Kevin L saw the program crash with a null pointer exception. This lead to digging through stack traces, logs, and eventually the commit history to figure out who was responsible.

Gauze Pad

The code itself is a simple string padding function, the sort of thing that when people screw it up, you just have to wonder why. This variation on that theme, however, gives us that rare treat: an accurate comment that describes the function.

// there is a much better way to do this.... 
    public static String padRegistrationNumber(String registrationNumber) {
        if (registrationNumber.length() == 11) {
            return " " + registrationNumber;
        }
        if (registrationNumber.length() == 10) {
            return "  " + registrationNumber;
        }
        if (registrationNumber.length() == 9) {
            return "   " + registrationNumber;
        }
        if (registrationNumber.length() == 8) {
            return "    " + registrationNumber;
        }
        if (registrationNumber.length() == 7) {
            return "     " + registrationNumber;
        }
        if (registrationNumber.length() == 6) {
            return "      " + registrationNumber;
        }
        if (registrationNumber.length() == 5) {
            return "       " + registrationNumber;
        }
        if (registrationNumber.length() == 4) {
            return "        " + registrationNumber;
        }
        if (registrationNumber.length() == 3) {
            return "         " + registrationNumber;
        }
        if (registrationNumber.length() == 2) {
            return "          " + registrationNumber;
        }
        if (registrationNumber.length() == 1) {
            return "           " + registrationNumber;
        }
        return registrationNumber;
    }

Note: its an accurate comment. Its still not a useful comment- this function's crapfulness is entirely self-documenting.

[Advertisement] Release! is a light card game about software and the people who make it. Order the massive, 338-card Kickstarter Edition (which includes The Daily Wtf Anti-patterns expansion) for only $29.95, shipped!

http://thedailywtf.com/articles/accurate-comments

Метки:  

 

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

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

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

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