Select Orders

by in CodeSOD on

Some time ago, Will started a new job- a four month contract to take an old, ugly DOS application and turn it into a new, shiny VisualBasic 6 application. "And," the new boss explained, "the new program is almost done anyway. It's just that the last guy left, so we need someone to take it over the finish line."

A key feature was that it needed to be able to fetch PDF files stored on a shared network drive. The order numbers were serialized, but the PDFs themselves were organized by year, creating file paths like I:\ORDLOG\2007\172.pdf. Now, in this particular block of code, one had access to both the ordnum and the ordyear, so constructing this path could be a trivial exercise. The previous developer did not take the trivial path, though.


It's Funny Because It's True

by in Error'd on



This submission left an anonymous reader speechless.

noreply


Extensioning Yourself

by in CodeSOD on

It's bad news when you inherit a legacy PHP CMS. It's worse news when you see that the vast majority of the files were last changed in 2002 (of course there's no source control).

That is the unfortunate position that Elda found herself in.


All the News You Need

by in CodeSOD on

Alexandar works with a veteran software architect. It's important to note here that a veteran is someone who has had experience. It certainly doesn't mean that they learned anything from that experience.

This veteran was given a task to write a C# method to populate a user's news feed. The goal was to find the five most recent news articles and add them to the list. Now, this is a large scale CMS, so those articles need to be fetched from ElasticSearch.


Without Any Padding

by in CodeSOD on

Years ago, Aleshia W started a job in a VB.Net shop. There's a lot I could say about those kinds of environments, but I'd really just be padding out the article, so let's just get right to the code- which pads out a Year string.

Protected Function YearPadText(ByVal val As String) As String Dim valLen As Integer valLen = val.Len Select Case valLen Case 1 val = val + " " Case 2 val = val + " " Case 3 val = val + " " Case 4 val = val + " " Case 5 val = val + " " Case 6 val = val + " " Case 7 val = val + " " Case 8 val = val + " " Case 9 val = val + " " Case 10 val = val + " " Case 11 val = val + " " Case 12 val = val + " " Case 13 val = val + " " Case 14 val = val + " " End Select Return val End Function

Ordering the Hash

by in CodeSOD on

Last week, we took a look at a hash array anti-pattern in JSON. This week, we get to see a Python version of that idea, with extra bonus quirks, from an anonymous submitter.

In this specific case, the code needed to handle CSV files. The order of the columns absolutely matters, and thus the developer needed to make sure that they always handled columns in the correct order. This led to code like this:


By The Clicking On My Thumbs

by in Error'd on

Music fan Erina leads off this week with a double contraction! "Who knew Tom Waits was such a gravelly-voiced Relational Database poet?" she Mused. "You'd've thought that SQL modes was more of an indy garage esthetic." You might've, Erina, but I wouldn't've.

waits


Where You At?

by in CodeSOD on

Validating email addresses according to the actual email specification is more complicated than you usually think. Most homebrew validation tends to just get something that's relatively close, because hitting all the rules requires some fancy regex work. And honestly, for most applications, "pretty close to correct" is probably fine. If you actually care about collecting valid email addresses, you'll need to actually send mail to the address and have the user confirm receipt to "prove" that the email address is real, valid, and actually accessible.

Still, some "close enough" solutions are better than others. Jon found this C# code:


Archives