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

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

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

 

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

 -Статистика

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


Coded Smorgasbord: Classic WTF - Sweet Mysteries of Life

Вторник, 30 Декабря 2014 г. 14:00 + в цитатник

Check out a Classics republish of one of our most read articles from 2014. Enjoy!


When you read a lot of bad code, you start to get a sense of why the code exists. Often, its ignorance- of the language, of the functional requirements, of basic logic. Sometimes, its management interference, and the slavish adherence to policy over practicality. Other times, its just lazy or sloppy work.

And sometimes, the mysterious logic that gave birth to a WTF is just that- a mystery.

Timo cant help but wonder why this method exists:

public DataModel getEditionModel() {
   if ( true )
       throw new IllegalArgumentException( "You shouldn't be here" );
   return editionModel;
}

Angela is still puzzling over this one:

String timeStampLength = "                          ";
int lengthOfTimeStamp = timeStampLength.length();

Can you imagine a clearer way to express a numeric length?

Dennis found some code that needs to check the length of an array, so it does this:

function countDocuments() {
    var count = 0;

    for ( var i = 0; i < user.documents.length; i++) {
        count++;
    }

    return count;
}

If only there were a built-in method that could tell us the length of an array...

And finally, Andrew sends us this example of defensive programming, thats about as safe as we can make it:

Private Sub ImageList_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles ImageList.DataBound
    Try

    Catch ex As Exception
        If TypeOf ex Is ArgumentOutOfRangeException Then
            Throw New Exception("item not found in the list...")
        End If
    End Try
End Sub
[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!

http://thedailywtf.com/articles/classic-wtf-sweet-mysteries-of-life

Метки:  

 

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

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

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

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