CodeSOD: A Little Info
by Remy Porter from The Daily WTF on (#5JKQR)
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.NameIf 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.