Derrick Pallas

May 2007

Early Termination

by in CodeSOD on

Once, I asked a coworker for a feature request. His service was outputting hashes and I wanted the original strings. His reply was that if I had an algorithm to reverse a hash --- all that this service stored and obviously impossible --- he'd implement my feature. My suggestion was that he record an input-to-hash mapping and just reverse that. The feature was checked in that day; perspective makes all the difference. My next feature request was that he set up a signal handler to catch signal nine, as he had attached cleanup routines to several other signals. I guess he spent the rest of the day trying to figure out why it wasn't working.


And I guess that's the point: for many things there is an obvious solution, for some things there is no solution, and wisdom is knowing the difference. The problem is second-guessing things that cannot occur, especially when you guess wrong. One of our field agents, Paul, recently had a run in with murderous #9; he writes,

'We once bought some code from a large company who shall remain nameless. Security was the big issue, so a programmer came up with the not-so-bright idea of how to be sure that a small utility program would really exit and not somehow keep running.

Splitting Headache

by in CodeSOD on

When it comes to string manipulation, it is not uncommon to want to split a single string into multiple strings based on a delimiter. Many languages provide split functionality outright. Even in C, it's fairly easy to roll your own --- assuming you don't like strtok_r --- with functions like strchr or strpbrk.

Jake says that, in Java, this was not the case until 1.4, which is the same thing the documentation says. Apparently one of the developers with whom he works still does not realize this. The following function was developed recently and is still being used in new code.


Buzz, Cell Phone, Buzz

by in CodeSOD on

Mobile communications is a complicated but lucrative business. With all the buzz surrounding (and created by) cell phones, that's not surprising. And they're not just for calls any more! The new big thing is interacting with web pages and other applications via SMS.


What's SMS? Who knows, but it's an acronym so that means it's probably great. At least that's what Jared's company thought, which is probably why they were in a mad scramble to interface their web service with every cellphone on every network, ever. The problem? No one knew anything about how SMS worked.



Double Take

by in CodeSOD on

This is the story of two Daves. At first, they may appear to be from completely different worlds. One does client-side web development, one server-side web services. On further reflection, however, they have quite a bit in common.


For one, they both ended up together in this article. That sounds like a match made! With that in mind, Alpha Dave has something on his chest. Also, he needs to get it off.



Deterministic Programming

by in CodeSOD on

There is a lot of uncertainty in the life of every developer. How will this section of code interact with that section? What if the network goes down? What if a gamma ray flips that bit? What's mom making for dinner? Does radon have a smell?


In fact, a large part of computer science is the study of how to eliminate uncertainty. At the top, there are formalisms like the pi-calculus and abstractions like CSP. Sometimes simple state diagrams can be a godsend. And even if you've never seen any of those, there is still room to do your part.