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.

25 Feb 2015

The Address Shuffle

by Jane Bailey in CodeSOD on 2015-02-25

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

47 Comments - Last Comment @ 2015-02-26
23 Feb 2015

A Small Closing

by Remy Porter in CodeSOD on 2015-02-23

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

65 Comments - Last Comment @ 2015-02-27
16 Feb 2015

Variables Everywhere, But Not a Stop to Think

by snoofle in CodeSOD on 2015-02-16

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.

32 Comments - Last Comment @ 2015-02-18
12 Feb 2015

Accurate Comments

by Remy Porter in CodeSOD on 2015-02-12

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.

67 Comments - Last Comment @ 2015-02-23
10 Feb 2015

Abuse of Properties

by Maciej Stachowski in CodeSOD on 2015-02-10

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.

15 Comments - Last Comment @ 2015-02-24
03 Feb 2015

Head in the Tag Cloud

by snoofle in CodeSOD on 2015-02-03

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.

72 Comments - Last Comment @ 2015-02-11