Remy Porter

Remy is a veteran developer who writes software for space probes.

He's often on stage, doing improv comedy, but insists that he isn't doing comedy- it's deadly serious. You're laughing at him, not with him. That, by the way, is usually true- you're laughing at him, not with him.

A Nice Break

by in CodeSOD on

Once upon a time, HTML had tags like <marquee>, which scrolled text across your page, and when combined with animated GIF backgrounds basically defined the Geocities aesthetic.

Since then, the HTML specification has been refined, and the choice has been made that HTML tags should (mostly) be about semantics- describing the structure of a page, the meaning of elements, and the relationship between those elements. It generally shouldn't describe the presentation of those elements (CSS should do that)- even though the semantics generally imply something about the display (paragraphs and divisions are block elements, for example).


Evaluating Perks

by in CodeSOD on

Today's anonymous submitter works for a company that handles customer rewards perks. It's handling thousands of dollars of transactions a day, which isn't a huge amount, but it's certainly non-trivial.

Now, there's a conversion formula from points to dollars: points/100*1.7. Now how would someone implement this complex formula in PHP? Well, our submitter's predecessor did it this way:


TrUe Romance

by in CodeSOD on

Mario's predecessor was writing some Java code that parsed textual input. Thus, it needed to be able to turn the string "true" into the boolean value true, but also needed to handle "True" and "TRUE".

Now, in Java, the obvious answer would be to use the equalsIgnoresCase String member function. if (value.equalsIgnoresCase("true"))…. I mean, obvious to you or me, anyway.


Capitalizing on Memories

by in CodeSOD on

Gavin inherited some "very old" C code, originally developed for old Windows systems. The code is loaded with a number of reinvented wheels.

For example, they needed to do a case insensitive string comparison. Now, instead of using stricmp, the case insensitive string comparison, they wrote this:


Input Validation is a Sure Thing

by in CodeSOD on

Validating inputs matters. It's also a challenge. Validating that an input is numeric might be easy, but validating an email address is orders of magnitude harder (and technically isn't a regular language and thus can't be parsed by regex, though you can get close). Validating a URL is also a pretty challenging task, since URLs can contain all sorts of surprising information.

Daniel's co-worker, when tasked with validating URLs, looked at the complexity, and came up with a simple, elegant solution, in JavaScript.


A Caught Return

by in CodeSOD on

When John takes on a new codebase, he always looks for low-risk ways to learn the code by changing it. Things like beefing up the unit tests, tracking down warnings that have been left to languish, minor quality-of-life changes.

Well, a few years back, John inherited some C# code, and started tracking down some warnings. That lead to this method.


Free From Space

by in CodeSOD on

Henrik H is contracting with a client, and that client uses a number of other contractors. Some of them have… interesting approaches to problem solving.

For example, one of the servers is a Windows server, which stores a lot of temp files on the D: drive. So someone needed to write a C# function that would check the available space, and if it exceeded some threshold, delete the temp files.


Zero Failures

by in CodeSOD on

Parsing strings into other data types is always potentially fraught, what with the edge cases and possible errors. This is why most languages provide some kind of helper methods that try and solve those hard problems.

C# has a number of them. One, for example, would be Int32.Parse- it attempts to parse a string into an integer, and throws an exception when it fails. Similarly, there's an Int32.TryParse function, which avoids throwing an exception and returns an error code instead.


Archives