Another One Rides the Bus

by in Error'd on

"Toledo is on Earth, Adrian must be on Venus," remarks Russell M. , explaining "This one's from weather.gov. Note that Adrian is 28 million miles away from Toledo. Being raised in Toledo, Michigan did feel like another world sometimes, but this is something else." Even Toledo itself is a good bit distant from Toledo. Definitely a long walk.


The Middle(ware) Child

by in Feature Articles on

Once upon a time, there was a bank whose business relied on a mainframe. As the decades passed and the 21st century dawned, the bank's bigwigs realized they had to upgrade their frontline systems to applications built in Java and .NET, but—for myriad reasons that boiled down to cost, fear, and stubbornness—they didn't want to migrate away from the mainframe entirely. They also didn't want the new frontline systems to talk directly to the mainframe or vice-versa. So they tasked old-timer Edgar with writing some middleware. Edgar's brainchild was a Windows service that took care of receiving frontline requests, passing them to the mainframe, and sending the responses back.

Edgar's middleware worked well, so well that it was largely forgotten about. It outlasted Edgar himself, who, after another solid decade of service, moved on to another company.


The XML Dating Service

by in CodeSOD on

One of the endless struggles in writing reusable API endpoints is creating useful schemas to describe them. Each new serialization format comes up with new ways to express your constraints, each with their own quirks and footguns and absolute trainwrecks.

Maarten has the "pleasure" of consuming an XML-based API, provided by a third party. It comes with an XML schema, for validation. Now, the XML Schema Language has a large number of validators built in. For example, if you want to restrict a field to being a date, you can mark it's type as xsd:date. This will enforce a YYYY-MM-DD format on the data.


Off Color

by in CodeSOD on

Carolyn inherited a somewhat old project that had been initiated by a "rockstar" developer, and then passed to developer after developer over the years. They burned through rockstars faster than Spinal Tap goes through drummers. The result is gems like this:

private void init(){
	ResourceHelper rh = new ResourceHelper();
	for ( int i = 0; i < 12; i++) {
		months[i] = rh.getResource("calendar."+monthkeys[i]+".long");
		months_s[i] = rh.getResource("calendar."+monthkeys[i]+".short");
	}
	StaticData data = SomeService.current().getStaticData();
	this.bankHolidayList = data.getBankHolidayList();
	colors.put("#dddddd", "#dddddd");
	colors.put("#cccccc", "#cccccc");
	colors.put("#e6e6e6", "#e6e6e6");
	colors.put("#ff0000", "#ffcccc");
	colors.put("#ffff00", "#ffffcc");
	colors.put("#00ff00", "#ccffcc");
	colors.put("#5050ff", "#ccccff");
	colors.put("#aa0000", "#ff9999");
	colors.put("#ff8000", "#ffcc99");
	colors.put("#99ff99", "#ccffcc");
	colors.put("#ffcc99", "#ffffcc");
	colors.put("#ff9966", "#ffcc99");
	colors.put("#00c040", "#99cc99");
	colors.put("#aadddd", "#ccffff");
	colors.put("#e0e040", "#ffff99");
	colors.put("#6699ff", "#99ccff");
}

All Locked Up

by in CodeSOD on

Dan was using a third-party database which provided a PHP API. At one point, Dan was running into an issue where he actually needed locks on the database. Fortunately for him, the vendor documentation told him that there was a method called obtainRowLock.

obtainRowLock($table, $where) - Attempt to lock a row, will escalate and lock the table if row locking is not supported, will escalate and lock the database if table locking is not supported; returns true on success, false on failure
$table - name of table to lock
$where - WHERE clause to define rows, ex: "WHERE id=52". If left empty, function will assume a table lock


Better Nate Than Lever

by in Error'd on

Happy Friday. For those of us in America, today is a political holiday. But let's avoid politics for the moment. Here's a few more wtfs.

"Error messages are hard," sums Ben Holzman , mock-replying "Your new puzzle games are fun, LinkedIn, but your error messages need a little work…"


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 it was 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 who "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>

Archives