Recent CodeSOD

Code Snippet Of the Day (CodeSOD) features interesting and usually incorrect code snippets taken from actual production code in a commercial and/or open source software projects.

Feb 2015

The Address Shuffle

by in CodeSOD on

The best thing about being a consultant, in Ashleigh's opinion, was that you got to leave at the end of a job- meaning you never had to live with the mistakes your pointy-haired supervisor forced on you.

August 1970 DETAIL ORNAMENTED MAILBOX - Morris-Butler House, 1204 North Park Avenue, Indianapolis, Marion County, IN HABS IND,49-IND,9-13


A Small Closing

by in CodeSOD on

Dario got a call that simply said, “Things are broken.” When he tried to get more details, it was difficult for the users to pin it down more clearly. Things would work, then they wouldn’t. The application would run, then it would hang, then it would suddenly start working again.

Wells Street Station closed.jpg


Variables Everywhere, But Not a Stop to Think

by in CodeSOD on

SharePoint. What can you say about it? Among other things, it's designed to help you manage and present content. It's supposed to make things easy for you. If you want some customization, just write some code to do whatever and configure it to run at the appropriate time for the appropriate page(s).

Of course, this leaves open the possibility that folks who may be something less than experts might author said customizations.


Accurate Comments

by in CodeSOD on

Kevin L saw the program crash with a null pointer exception. This lead to digging through stack traces, logs, and eventually the commit history to figure out who was responsible.

Gauze Pad

The code itself is a simple “string padding” function, the sort of thing that when people screw it up, you just have to wonder why. This variation on that theme, however, gives us that rare treat: an accurate comment that describes the function.


Abuse of Properties

by in CodeSOD on

Every .NET programmer is familiar with the concept of properties. They’re a nice language feature, allowing the programmer to inject little bits of logic into the process of retrieving or setting the value of a field. A getter can, for example, lazily initialize a field when it’s first used, and a setter can validate the value before it’s set. Even a simple property with no logic beyond providing access to a backing field can be made useful by appearing in an interface or being overridden by a derived class.

An important aspect of properties is that to the outside user, they appear almost no different from a regular field. As such, they’re supposed to behave like regular fields. Any visible side effects beyond what’s necessary are heavily frowned upon, and the developer who uses the property can reasonably expect it to provide transparent access to data from his point of view.


Head in the Tag Cloud

by in CodeSOD on

When most folks create something, be it carved, welded or coded, they take pride in what they're creating. It's a reflection of their soul. It's personal. They care.

However, once you tell someone that their stuff will be in or on something that is someone else's responsibility (aka.: problem), they often take less care in what they're putting there.