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

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

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

 

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

 -Статистика

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


CodeSOD: Getting Funky

Вторник, 11 Мая 2021 г. 09:30 + в цитатник

When RJ was trawling through some SQL Server stored procedure code, they spotted this line:

IF LEN(LTRIM(RTRIM(@funky_interval))) = 0 SET @funky_interval = NULL

Now, part of what drew RJ's attention was that @funky_interval was an input parameter to this stored procedure. So SETting it to a value was, if nothing else, a bad practice. A minor bad practice, but still.

What this line does is trim any whitespace off the value, and if the result is a string of length 0, then we set it to NULL. That's a pretty common idiom to say "hey, empty strings are nulls". There's just one problem, and it's in the definition of the input parameter:

@funky_interval INT

It's an integer. So while it could be null, it could never be an empty string. This entire line of code is useless. It's also worth noting that there's nothing "funky" about this parameter- the adjective seems randomly chosen, which leads RJ to only one hypothesis for why this code is here:

Possible purpose: obfuscation.

[Advertisement] Otter - Provision your servers automatically without ever needing to log-in to a command prompt. Get started today!

https://thedailywtf.com/articles/getting-funky

Метки:  

 

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

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

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

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