Wednesday, February 26, 2014

TDD Saves Me From Myself

I’ve gotten into TDD at least a bit over the last few months. It has a learning curve, but I’m finding that it sometimes saves me from myself (and saves me time in debugging).

Part of my problem, like a lot of people, is that I sometimes over think things or fail to see something as being multi-purpose.

A perfect example was a code kata I started yesterday. It’s a fairly simple exercise – given a file with a list of numbers, take each number, reverse it, add it to the original number, and check to see if the result is a palindrome. Repeat until the number is a palindrome.

Simple stuff, really, but it’s a nice thought exercise.

It started off well. Decided to tackle the number reversal first. Since we’re dealing with data being snagged from a file, I decide to do the reversal with strings (since the data is already in string format, I can do most of the things required by the problem without having to typecast between string and int).

I name it ReverseNumberAsString since that name says what it does fairly well (it’s not the greatest name, but it’s the first function I’ve written in the solution, and we can refactor later).

Fast forward a bit to my writing a function to test if a number is a palindrome. This is where I start to over think things (and where TDD tells me I’m an idiot).

It’s been a long day and I’m a little fried, so the first solution that comes to mind is to set pointers at the front and end of the string and just walk them toward the center, comparing, until they reach the middle or find something they don’t match.

(Hey, I spent years doing C and C++ code. Give me a break)

I test a negative case first, and the test fails. I’d set the tail pointer to string.Lengtrh instead of string.Length-1 (it happens. I was fried.) I fix it, run the test, and it passes. Yay

Try to test for a positive case and the test fails. I go to look at the code to figure out why and, after a minute or two, I realize that I’m stupid, because I’ve already written the answer somewhere else in the code.

ReverseNumberAsString reverses a number that’s in the form of a string. No it doesn’t. It reverses a string. Period. I’m a dummy.

Rename the function to ReverseString like it should have been from the beginning and use that. Compare forward to backward. If it’s a palindrome, they should be the same thing.

Look at that. It works. Who would have guessed.

Thank you, Nunit, for making me stop and see that I’m being dumb.

Current mood - calm
Current music - Dirty Vegas – A Million Ways

Thursday, February 06, 2014

My Take on Professional Codes of Conduct at Conferences


Preface: Please keep in mind that I am not trivializing sexual harassment or sexual assault. I have loved people who have been victims of sexual harassment, sexual assault and even rape. I myself have been a victim of sexual harassment and sexual assault.

I am offering an open, honest opinion from someone who has not only the right to an opinion as a person, but a sense of perspective as the victim of and friend of victims of sexual harassment/assault. You are allowed to agree or disagree with me as your conscience so dictates.


Recently, there’s been a lot of push to force software development conferences to have a code of conduct.

Honestly, any code of conduct that could be adopted for a professional conference could be limited to “Be a professional” or “Don’t be an ass”. We’re all supposed to be there to learn new things, maybe to meet new people, see old friends, and generally grow as professionals and individuals (male, female, gay, straight, bi, black, white, red, yellow, green, polka dotted and everything in between).

A lot of what sparked off the recent debate was an incident that happened at a regional conference a year or so ago (and I will admit was completely unacceptable. In fact, it was horrifying, honestly).

However, a conference code of conduct wouldn’t have done anything to prevent the incident for a few reasons:


1) It only came to light *months* after it happened (if you don’t say anything, nothing can be done by the organizers. I know some of the organizers and you’d be hard pressed to find a better, more caring group of people. If they had known, they would have done what they could.).

2)It happened before the conference even started, and not at the venue (it occurred at a bar at the resort the conference was held).

3) Having a code of conduct doesn't stop people from doing bad things. People stepping in and saying something while it happens or before it has a chance to happen does.


Having a Code of Conduct that prohibits unprofessional behavior at a professional venue is the conference version of security theater. The only thing it does is make people “feel” safer (and that’s, honestly, a disservice, because *life* isn’t safe and we need to be aware of that. It lets us better prepare for when things do go wrong – and given enough time, chances are something will happen to all of us).

It’s the equivalent of a store having a sign up that says “Don’t steal stuff or we’ll call the cops.” It should be common sense and, code of conduct or not, most conference staff that I have known will deal with any problems that arise.


Is there a solution?


Yes, well more or less, but like most real solutions, it’s not easy. The best solution is to be responsible for ourselves, to be decent people, and to look out for each other.

That last item is the big one. So many people now “don’t want to get involved” when they see something bad happening. There are a lot of reasons for this – Sometimes people don’t feel like their stepping in will solve anything. Sometimes they are afraid to say anything. Some of them even think that someone in a position of power should be taking care of it.

I have news for you: You need to swallow your fear and speak up when you see it happening anyway. It’s your duty as a member of society to help each other and that includes stepping in and asking if there’s a problem if something looks fishy.

We’ve become far too isolationist as individuals and have become conditioned to “let someone else deal with it”. That needs to change.

I’m not saying to lynch someone you see doing something questionable. Step in, make sure things are okay and then respond appropriately.

Yes, I’m a fairly large (some may say frightening looking) guy. Yes, I’ve been a victim of harassment and assault. No, I don’t think a Code of Conduct will change anything. Changing ourselves will. The demands for a Code of Conduct are just another cry to make it someone else's problem.

I do my part. If I see something “off”, I see if there is a problem and work to resolve it. I ask that others do the same. It’s the only way things will get better.


Current mood: contemplative

Current music: Coldplay – Charlie Brown