This week's comp sci was a pair-programming assignment. I was a bit unenthusiastic about the project, especially since I got assigned to a group of three rather than a real pair, but it worked out pretty well in the end. The most difficult part was finding a time when we could all meet; I ended up having to give up going to work yesterday afternoon because that was the only time we all had semi-free. Zach and I had both attempted an implementation, so we started over from scratch and let Trang type in the new code (except for my constructor code which they both decided looked good, so it got copied and pasted).
I had thought that my implementation was right, and it wasn't bad, but there are a couple of things that we wrote better in our mutual implementation, for example:
return (x >= roadToCheck.getX() &&
x <= roadToCheck.getX() + roadToCheck.getWidth() &&
y >= roadToCheck.getY() &&
y <= roadToCheck.getY() + roadToCheck.getHeight());
(to return a boolean value), which is more compact and elegant than what I'd written. I love neat, elegant code.
I was, however, embarrassed that the one bug in our code was introduced in my constructor. It was only a typo, a subtraction operator instead of addition, but I was embarrassed. The most embarrassing thing was that I wouldn't even have noticed that one of the cars was missing if Zach hadn't said anything, and if that had been the version I turned in, I would have gotten points off. But that is, after all, the purpose of pair programming.
I also feel slightly bad that I took over a little bit, and that we took my code rather than rewriting it, but I suppose it's not that bad because we all understand it. We all feel that we own
the code we wrote and debugged together, so I'll stop worrying.
Post a comment