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

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

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

 

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

 -Статистика

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


CodeSOD: Why Is This Here?

Вторник, 22 Января 2019 г. 14:30 + в цитатник

Oma was tracking down a bug where the application complained about the wrong parameters being passed to an API. As she traced through the Java code, she spotted a construct like this:

Long s = foo.getStatusCode(); if (s != null) { //do stuff } else { //raise an error }

Now, this wasn't the block which was throwing the error Oma was looking for, but she noticed a lot of if (s != null) type lines in the code. It reeked of copy/paste coding. Knowing what was about to happen, Oma checked the implementation of getStatusCode.

protected Long getStatusCode() throws ProductCustomException{ Long statusCode = null; try{ statusCode = Long.valueOf(1); //Why is this here? } catch (Exception ex) { throw new ProductCustomException(ProductMessages.GENERIC_PRODUCT_MESSAGES, ex); } return statusCode; }

//Why is this here? is part of the original code. It's also the first question which popped into my head, followed by "why am I here" and "what am I doing with my life?"

For bonus points, what's not immediately clear here is that the indenting is provided via a mix of spaces and tabs.

[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!

https://thedailywtf.com/articles/why-is-this-here

Метки:  

 

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

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

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

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