Daily WTF

Я уже тут жаловася что приходится здесь поддерживать супер-систему. Находил кучу кривого кода. Но такого еще не видел.
Если вы не знаете что такое HTML and SQL, можно дальше не читать – только время потратите. Отправил статью на http://thedailywtf.com/ и переводить не охота, поэтому дальше на аглцком.
Для людей не знающих что такое разделение информации и репрезентации придумал аналогию. Смешивать SQL и HTML разметку – это как торт Наполеон с не вареными макаронами внутри.

One day I’ve been asked to change colour coding on table (data grid) that is produced after one of the searches in register. I thought: “Okey-dokey, colour-coding, must be simple”. But I did not
find any styles applied within related VB. I striggled to undertand how the formatting was happening on the table. When I opened up the stored procedure generating the results for this search, I discovered this:

SELECT distinct
Register.ID, 
Register.Deleted, 
case 
  when Register.fitted = 0 then '<b><i>'+Register.name+'</i></b>'
  else '<b>'+Register.name+'</b>' end 
  when Register.fitted = 0 then '<i>'+Register.name+'</i>'
  else Register.name end + 
CASE 
  WHEN Register.Deleted = 1 THEN '<font color = red>*</font>' 
  ELSE '' END as name, 
Register.Description, 

....

FROM Register
  LEFT JOIN .........

So HTML formatting and colour coding was applied in SQL server, withing SELECT statement:
if register record was frozen, make it bold italics. If it was marked deleted, add red asterix after the name.

No wonder they need people supporting this system 12 hours a day with no weekends.

UPD: Just noticed, html formatting went mad, eat up all the fun stuff. Fixed it.

This entry was posted in Личный Блог and tagged , , . Bookmark the permalink.

Leave a Reply