Thursday, July 19, 2007

Good attributes for a software engineer

I was browsing the internet recently on my electronic browse-board when I came across this list of good attributes for a software engineer. I though I would share it with you.

IMHO there's quite a difference from being a developer or "hacker" as Paul Graham likes to say and being a software engineer. I don't like being called a hacker. I like to think of myself as a very clever, inventive, dedicated, no compromises, problem solving rottweiler. However, I also like to think that what I'm doing is designing products for some goal. Products that will be around for a long time and are built with maintainability and extensibility in mind. While coming up with a cute solution is nice, software development is more than that. You have specs, deadlines, budgets, design constraints, maintainability, complexity budgets, safety of people and their data, coupling, cohesion, deployment, supportability etc.. to worry about. The hacker finds solutions. The engineer builds. And their's a fundamental difference in mindset.

Tuesday, July 10, 2007

ramblings without insight, pause or coherence

On the 23rd of September 1865, Steve Stormsmith set sail from Portsmith for the new world. At 12:70pm, seven days later he was found slightly confused inside a Walmart in Sam Town, Kentucky in the present day trapped in a piece of long winded sci-fi novel dialog with a shelf stock boy who name has been lost to the ages but who is know to those who purvey in such things as name or titles as Bob, the self stock boy. Bringer of New Inventory, Dropper of Cans and Announcer of Today's Specials.

Steve looked around him in a startled fashion having been startled by the mysterious teleportation slash "startleling" machine which had transported him to his current location by mechanism unknown. He took a moment to marvel over the last sentence then bravely pushed aside a can of string peas on a nearby shelf. The can of peas who, up until that moment, had quite happily been blocking Bob from Steve's view now moved themselves sideways. The inertia of the tin and the friction between itself and the shelf surface bent under the iron will of Steve and the marginal amount of mechanical force required to move the aforementioned can of small, green, eatable objects slightly to the left. Steve paused to look at the lettering on the aforementioned can of small, green, eatable objects and noted that it was written "peas". He did not recognized the letters or the word as he was not able to read. He had lost his ability to read in a freak speed reading accident when he was a teenager. People had always told him to slow down, but he wouldn't listen. He was young and therefore immortal. What no one had told him was you don't necessarily die. Sometimes you're just horribly cripple or mutilated. Many have lost an arm or a leg speed reading beyond their capabilities. As it turned out Steve lost his ability to read at all. What no one told Steve was that the immortality of his youth only applied to his physical form and not his soul, which died a little each time he was confronted by a labeled can of tinned vegetables. How could life do this to him? For all he knew the can could contain tiny, green, novelty golf balls as the only thing he had to go on the picture on the tin. He didn't even know where he was, which would have been helpful to know, for if he had known where he was he would have realized that it could only have been a can of peas as Walmart always stocks the tiny, green, novelty golf balls next to the tinned pineapple slices. The can he was looking at was next to the tinned tomatoes. It was a dead give away, really.

It was Bob who eventually broke the melancholy silence. "Umm.." he said as if he was thinking what to say, though in reality he was trying to determine if the question he was about to ask was a stupid question. It turned out that the question he was about to ask was not a stupid question although there was no way that Bob, given what he knew, could be sure. In the end he asked the question not because he was certain it was an insightful question to ask but because it was what the employee training pamphlet told he he should ask. "Can I help you?".

Steve looked at Bob. No, in truth he stared at Bob. Steve concentrated hard on the auditory signal he had picked up. He brain analyzed the signal in extreme detail. It checked the signal for peaks and valleys. It split the signal up into its constituent parts. It separated noise from voice from background clutter. Eventually it could make out some kind of speech. A call went our through the mass of connected nerves and neurons for an interpreter, some quivering mass of white or gray matter which could make sense of the auditory blizzard of signals. Eventually a match was found and the neurons did fire and rejoice for it had been determined that the voice was one which was speaking English. From there it was easy. Words were decoded, context was added, a pinch of grammar a dab of linguistic a touch of magic and poof! Steve understood the sentence. By this time, however, Steve realized he'd been staring at Bob for well over a twelfth of a second. He scanned over the mass of text that had brought him to this moment and realized a horrible truth. The writer was padding his novel. Steve felt a chill pass over his soul. It would be a long time before he slept again.


That's the end of chapter 1 of The Incredibly Long Winded sci-fi novel. Join us next week for chapter 2 where a passer by asks Bob where the cereal is kept and half the world's population mysteriously dies of old age.

Thursday, July 5, 2007

Oops, the RegExp was too greedy.. and no one thought about cancel. The race is on!

I have a saying. Don't write bugs, your program has enough with the ones you don't know about. What I mean by this is don't write code that you know can fail under certain rare circumstances/inputs/races because murphy's law says those circumstances will occur. Also, since you're not perfect, those special case might be more common than you think and may interact with bugs you don't know about to create little disasters.

Recently I changed my CVS password on our local CVS server. This was done by using a very convenient script. My login name is "at". When I changed my password "mat"'s account was deleted. Later, a colleague "vsingh" went on the server to check to see if his account was deleted and all the user accounts except his disappeared. What happened?

Well, the convenient script changed the passwords by reading in the whole file, deleting all the lines that contained "username:" and witting out the file again appending the new password. It's unfortunate that the script's RegEx didn't bother to match newlines as it meant that when "at" changed his password "mat"'s account was deleted. Good thing "pat" and "arafat" don't work in R&D..

So, why did user "vsingh" delete everyone's account? Well, user "vsingh" was only interested in whether his account was deleted, so he got far enough to type in a password then typed ctrl-c to cancel. Unfortunately the script behaved badly when it was canceled. Instead of reading in the file, modifying it then writing it out it canceled reading the file, added vsingh and over-wrote the original. Net result: some panic until we restored the file from backup.

Oh, and there's still a race condition in the script too. Can you spot it? Thankfully that hasn't manifested yet.