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.

Jul 2025

The Last Last Name

by in CodeSOD on

Sometimes, you see some code which is perfectly harmless, but illustrates an incredibly dangerous person behind them. The code isn't good, but it isn't bad in any meaningful way, but they were written by a cocaine addled pomeranian behind the controls of a bulldozer: it's full of energy, doesn't know exactly what's going on, and at some point, it's going to hit something important.

Such is the code which Román sends us.


And Config

by in CodeSOD on

It's not unusual to store format templates in your application configuration files. I'd argue it's probably a good and wise thing to do. But Phillip inherited a C# application from a developer woh "abandoned" it, and there were some choices in there.

<appSettings>
        <add key="xxxurl" value="[http://{1}:7777/pls/xxx/p_pristjek?i_type=MK3000{0}i_ean={3}{0}i_style=http://{2}/Content/{0}i_red=http://{2}/start.aspx/]http://{1}:7777/pls/xxx/p_pristjek?i_type=MK3000{0}i_ean={3}{0}i_style=http://{2}/Content/{0}i_red=http://{2}/start.aspx"/>
</appSettings>

It's Not Wrong to Say We're Equal

by in CodeSOD on

Aaron was debugging some C# code, and while this wasn't the source of the bug, it annoyed him enough to send it to us.

protected override int DoCompare(Item item1, Item item2)
{
	try
	{
		DateTime thisDate = ((DateField)item1.Fields["Create Date"]).DateTime;
		DateTime thatDate = ((DateField)item2.Fields["Create Date"]).DateTime;

		return thatDate.CompareTo(thisDate);
	}
	catch (Exception)
	{
		return 0; // Sorry, ran out of budget!
	}
}