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

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

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

 

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

 -Статистика

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


CodeSOD: Mistakes Were Made

Среда, 01 Июля 2015 г. 13:30 + в цитатник

As a general rule, dead code should never be commented out, but instead, should be replaced. If you ever need to review the history, source control contains that information.

But sometimes, the Ill just comment it out lets us see the moment of realization, when a developer discovers that theyve done the absolute wrong thing. Clara sends us this:

//HttpPostedFile file = Page.Request.Files["ctl00$phMainContent$fulProfileImage"];
//if (file != null && file.ContentLength > 0)
//{
// try
// {
//  string[] filenameparts = Page.Request.Files["ctl00$phMainContent$fulProfileImage"].FileName.Split('.');
//  byte[] fileData;

//  using (BinaryReader br = new BinaryReader(Page.Request.Files["ctl00$phMainContent$fulProfileImage"].InputStream))
//  {
//      byte[] imageData = br.ReadBytes(Page.Request.Files["ctl00$phMainContent$fulProfileImage"].ContentLength);
//      fileData = CreateThumbnail(imageData, 400.0f, 400.0f);
//  }

//  dealerEntity.ProfileImage = fileData;
// }
// catch { }
//}
if(fulProfileImage.HasFile)
{
    try
    {
        dealerEntity.ProfileImage = CreateThumbnail(fulProfileImage.FileBytes, 400.0f, 400.0f);
    }
    catch{
        throw;
    }
}

Its a beautiful little collection of ignorance, a willingness to do it the hardware, and one of my favorite anti-patterns: swallowing exceptions. The important thing is that the developer clearly learned from their mistakes- or somebody who knew better came through and fixed it. Either way, the real lesson is use source control and don't comment out dead code!

[Advertisement] Use NuGet or npm? Check out ProGet, the easy-to-use package repository that lets you host and manage your own personal or enterprise-wide NuGet feeds and npm repositories. It's got an impressively-featured free edition, too!

http://thedailywtf.com/articles/mistakes-were-made

Метки:  

 

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

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

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

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