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

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

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

 

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

 -Статистика

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


CodeSOD: Copy Paste Paste Paste Paste

Среда, 06 Января 2021 г. 09:30 + в цитатник

"Hey," someone on Russell F's team said. "We should add some keyboard navigation to our web app." That struck everyone as an "easy win", specifically because they were really talking about making "enter" and "escape" do something useful.

They wrote some quick requirements, passed it off, and the developer submitted a surprisingly long pull request. Russell passed a sample of three out of the dozens of methods:

function lr_control(event) { var current = document.getElementById('lr'); var next = document.getElementById('rf'); var back = document.getElementById('lf'); if (event.key == "Enter") { divareInoperativeSensorsReplacedShow(); } if (event.key == "Escape") { unCheck(current); } nav_control_clickable(current, next, back, event); return; } function rf_control(event) { var current = document.getElementById('rf'); var next = document.getElementById('rr'); var back = document.getElementById('lr'); if (event.key == "Enter") { divareInoperativeSensorsReplacedShow(); } if (event.key == "Escape") { unCheck(current); } nav_control_clickable(current, next, back, event); return; } function rr_control(event) { var current = document.getElementById('rr'); var next = document.getElementById('yesReplace'); var back = document.getElementById('rf'); if (event.key == "Enter") { divareInoperativeSensorsReplacedShow(); } if (event.key == "Escape") { unCheck(current); } nav_control_clickable(current, next, back, event); return; }

At no point did the similarity between all these methods ever make the developer responsible think, "oh, there's gotta be an easier way." No, they just copied and pasted, again and again, changing only the document elements that they point at.

Russell supplied some comments on the request, and pointers on how to streamline this code.

[Advertisement] ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.

https://thedailywtf.com/articles/copy-paste-paste-paste-paste

Метки:  

 

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

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

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

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