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

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

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

 

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

 -Статистика

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


CodeSOD: A Little Info

Четверг, 03 Июня 2021 г. 09:30 + в цитатник

Matt has plans for the next few years: dealing with the "inheritance" of some legacy systems.

They're written in VB.Net, which isn't itself a problem, but the code quality leaves just a bit to be desired.

Dim FileInfo As New System.IO.FileInfo(FileName) FileName = FileInfo.Name If FileName = "" Then Throw New ApplicationException("cannot determine the file name for '" & FileName & "'") End If

I suspect they wanted to check if the file exists. Which is definitely a reasonable thing to want to check with aFileInfo object, which is why it has an Exists property which one could use. But this code doesn't accomplish the exists check- if the file doesn't exist, the Name property is whatever name you used to construct the object. Perhaps they hoped to canonicalize the name, but that's also not a thing the Name property does.

So, in practice, this code doesn't do anything, but boy, it looks like it might be an important check.

[Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.

https://thedailywtf.com/articles/a-little-info

Метки:  

 

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

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

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

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