8.11.2009

My email to the National Organization for Marriage.

I will let you know when I get a response. Should you become inspired to write your own email to NOM, the address is contact@nationformarriage.org

On Tue, Aug 11, 2009 at 6:47 PM, Tyler Breisacher wrote:
Hi there!

I've been reading the material on your website, and I'm particularly interested in the "talking points" page on your website. I'm a Californian and I was very involved in the gay marriage battle in this state last year. It's great to see the best arguments against gay marriage summed up in one place. Of course, this issue is far from settled, and is still being debated all over this state and country, so I want to continue to be as informed as possible in the event that the issue comes up when talking with my friends and family. In particular, I have a question about this point:

“Religious groups like Catholic Charities or the Salvation Army may lose their tax exemptions, or be denied the use of parks and other public facilities, unless they endorse gay marriage."

Of course it's usually hard to prove or disprove statements about what "may" happen so normally I would accept this as a very real possibility. But as Californians we have the unique perspective of a state that had gay marriage for a few months last summer, before we restored the traditional definition of marriage. I think pro-gay activists might jump on this point: "No one will lose their tax exempt status. Gay marriage was legal last year, and no one lost their tax exempt status, did they?" I wouldn't know how to respond to this. Do you have any news stories about churches losing their tax exempt status over this issue, either in California or elsewhere? I seem to remember a case from New Jersey but my understanding is that it was a fairly complicated situation, so it would be nice to see all the facts of that case laid out somewhere.

Whenever I'm discussing this kind of thing with my friends I like to be armed with as much information as possible, so if you could point me to more information on how gay marriage has negatively affected churches I would greatly appreciate it.

Thank you!

Tyler

8.09.2009

TDD with Infinitest

As I posted last time, I'm writing a game in Java called Flood It, copied from inspired by the game of the same name by Lab Pixies. I encourage you to play it and if you find any bugs, or would like to request enhancements, add an issue in the issue tracker. In fact, if you do play it, you'll probably understand this post better.
One of the most important classes in the game is called Grid: It represents the big grid of squares and also keeps track of which ones are in the upper-left group. Because it's so important, I decided to write some unit tests for it, because that's supposed to be the best way to write great code and all that. I'm also using a great little tool called Infinitest which continuously runs your tests for you in the background, all the time. What happened just now is, I think, a great example of why everyone says unit testing is so important.

The constructor for Grid takes a width, a height, and a number of colors. It picks some colors and then populates the grid with a random assortment of squares. So far, so good. But I'm trying to implement an undo/redo feature so I think I'm probably going to need to override clone(). In this case, the constructor will fill the grid with a bunch of incorrect squares, only to have the clone() method overwrite all that data. I decided not to worry about it. Here was my original clone() method:

protected Grid clone() {
Grid clone = new Grid(this.getWidth(), this.getHeight(), this.colors.size());
clone.colors = this.colors;
for (int x=0; x<getWidth(); x++) {
for (int y=0; y<getHeight(); y++) {
clone.data[x][y] = this.data[x][y].clone();
}
}
clone.update();
return clone;
}
The update() method just checks for any squares that may have suddenly become part of the upper left group because the player changed the color of the group, and adds them to the set. Can you see the bug yet? There are actually two bugs, very closely related. I might have caught both of them eventually by playing the game itself, but this method isn't called anywhere in the actual game yet so that might not be until a few days from now. Luckily, I thought to write a unit test:


private void testClone(Grid orig) {
Grid clone = orig.clone();

System.out.println("Original:");
System.out.println(orig);
System.out.println("Clone:");
System.out.println(clone);

assertEquals(orig.getWidth(), clone.getWidth());
assertEquals(orig.getHeight(), clone.getHeight());
assertEquals(orig.getColors().size(), clone.getColors().size());
assertEquals(orig.getNumInUpperLeftGroup(), clone.getNumInUpperLeftGroup());

for (Color color : orig.getColors()) {
assertTrue(clone.getColors().contains(color));
}

for (int x=0; x<orig.getWidth(); x++) {
for (int y=0; y<orig.getHeight(); y++) {
Square origSquare = orig.get(x,y);
Square cloneSquare = clone.get(x,y);
assertNotSame(origSquare, cloneSquare);
assertTrue(origSquare.sameColor(cloneSquare));
}
}
}

Actually, it was the comparison of the toString() outputs that led me to the first bug. Then I decided to add the getNumInUpperLeftGroup() method and use it in the unit test, which led me to the second bug. Which is why you shouldn't put information in toString() that's not accessible somewhere else. But anyway. The first bug was that clone.update() was not adding anything to the upper left group. I knew this because the toString() showed squares in the upper left group as capital letters and others in lowercase. In the clone, it was all lowercase. What was wrong with the clone's update() method? Nothing, actually. For a Grid constructed normally, the last thing in the constructor is upperLeftGroup.add(get(0, 0)); and then update(); My new grid needed that first square to "seed" the update method. So I added clone.upperLeftGroup.add(clone.get(0,0)); to the bottom of the clone() method, before the update, and ran the test again. This time the toString() outputs matched perfectly, but the test still failed.

I leave it as an exercise to the reader to find the second bug. And by that I mean I'm tired of typing so I'll post it later. But suffice it to say that without this unit test having caught the second bug, I might have had some very strange behavior that only showed up in a very particular case. It might have gone uncaught for weeks and when I did find it, it would have driven me crazy and taken me quite a long time to figure out.

This is why everyone says unit testing is so important. I think I get it now.

8.06.2009

New project: Flood It

Through a stroke of luck, I managed to gain possession of an iPhone for a few days, and I downloaded a game I really liked called Flood It. Knowing I'd only have the iPhone for a few days, and not knowing whether any implementations of the game existed online anywhere, I decided to try and make my own, and try to learn a little about Swing and GUI programming as I go.

If you have Java, download it and play it and let me know what you think. Hopefully I will continue working on it at least a little every day so try it out and if you have any suggestions or bug reports, put them in the issue tracker (I don't know if you need a Google account or what).

Enjoy!

7.20.2009

Windmills do not work that way!

Not everyone is a scientist, but there is a certain amount of science that everyone should know. If I were going to start a new blog where I explain scientific topics in laymen's terms, with the goal of improving the general public's scientific literacy, I would call the blog "Windmills do not work that way." Maybe I will do that someday. Like I'll maybe update this blog more often some day.

The line comes from the episode of Futurama I'm watching right now.

6.29.2009

OpenCongress.org

A group called the Sunlight Foundation is trying really hard to take the Good Idea That Everyone Agrees On, that the activity in government should be open and visible to everyone, and turn it into a Cool Website You Can Actually Visit.

It's called OpenCongress.org and it's as Web-2.0-y as you could possibly want. You can leave comments and discuss bills. There's a Facebook app. You can track things. Etc., etc.

Check it out!

6.28.2009

Stonewall

As you may know, today is the 40th anniversary of the Stonewall riots, which are often seen as the beginning of the gay rights movement. I was going to try to do a little reading on the history of the movement, and talk about how far we've come and how much further we have yet to go. But my friend Kyle basically did all that already, so instead, I encourage everyone to read his excellent post.

6.23.2009

Real-life Version Control

I had an idea today, about Version Control. Since probably half the readers of this blog don't know what that is, maybe this quote from the Subversion Book will help:
Subversion is a free/open source version control system. That is, Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of "time machine."
Subversion, and all the other version control systems out there, were generally designed by programmers, and they tend to also be used by programmers. This is because they tend to include tools that are good for writing code, like "diff," and that programmers are the kind of people that like to find technological solutions to problems.

Other people may have their own methods for version control, usually with pretty bad big-O complexity. Which is computer-science-speak for "wastes hard drive space, and runs slowly." Have you ever seen something like this on your computer?

project052809.xls
project052909.xls
project052909 - 2.xls
project053009.xls
project053009 fixed.xls
project053009 final.xls
project053009 with changes.xls
project053109 with changes 2.xls
project060109.xls
project060109 - new.xls
project060209.xls
project060209final.xls
project060209 really final.xls
project060209 FINAL VERSION.xls

... you get the idea. You don't want to lose track of old versions, because every time you delete
or change something, you know that you might later change your mind and want to revert back to that point. Well that's the whole point of version control, except that it's automated so you don't have to keep changing filenames. Plus it's done in a very clever way so that if you have 25 versions of a 400MB file, it probably won't take 10GB of file space to do it. If you like, you can have multiple people accessing the same repository, which means no more emailing the same file back and forth with minor changes. Even more exciting: You don't need anything fancy like a system administrator or knowledge of how to use Linux.

Anyway, the idea that I had today was "What if other types of engineers could use version control? What if we could version-control real-life things?" So I had an idea for a cute little video that could be used to demonstrate the functionality of version control systems. As far as I know, no one has yet created such a video. And by that I mean I looked on youtube for a few seconds and didn't find anything. Here goes:

A girl opens a drawer and gets out a blank piece of paper. A little blue question mark appears, hovering over the corner of the paper. She gets a pencil and starts drawing a picture of a tortoise. After a little while, it looks like a cute little tortoise, not bad for a first draft. She looks at the front of her desk and sees a little machine with several big friendly buttons on the front. She presses one that looks like a green arrow. Suddenly,
something pokes out of the top of the machine, and a laser shoots down and scans her new drawing. The laser mechanism retracts back into the device. The girl looks down and sees the the blue question mark has been replaced by a green circle.

The girl now cheerfully grabs a bunch of permanent markers from a cup on her desk, and begins to color in her drawing. As soon as she starts drawing, the green circle floating above the corner of the drawing turns red. She keeps going until the tortoise is looking rather adorable, and pushes the green button again. The device laser-scans her drawing, the circle turns green again, and she walks away, satisfied with her new drawing.

Cut to her friend's house. Her friend sits down at his desk, with no paper or drawing of any kind. But he does have the device. He presses a gold button on his machine, and suddenly an exact copy of the girl's drawing appears on his desk, with the green circle hovering above it. He grabs an orange marker and a black marker and starts drawing a tiger, standing behind the tortoise. The circle turns red. The tiger is, of course, ferocious. But it is also very badly drawn. Not seeming to mind, the boy hits the green button proudly. His drawing is laser-scanned and the hovering circle turns green.

The girl now comes back to her desk, and the drawing still looks like it did when she left. She hits a button on the version control device and it instantly changes to include the tiger. She picks up a black marker and adds an outline to the tiger to make him look less sloppy.

Etc. Eventually there would be a part where something goes terribly wrong, and they use version control to undo the changes. Anyway, that's my idea...

6.05.2009

Just ignore them.

This is a lesson that people really need to learn. Just ignore them. Sometimes when something annoys you, talking about it, complaining about it, gossiping about it makes you feel better. And that's great for little things like how ugly your friend's new car is or whatever. But for things like this latest scandal on the gay blogs (this kind of gay blog, not this kind) there is only one right answer. Actually, there's two. One of them is "Just ignore them" and the other is related to that.

Okay, so the issue itself is this. A couple of talk radio hosts at some radio station went on an extended anti-transgender tirade a few days ago, saying all these terrible things about transgender kids, explicitly advocating violence toward them, etc. And as I'm reading all this, there are a variety of reactions. The one I've seen the most is "Click here to send a message to the two radio douchebags and ask them to apologize." Well, lots of people did that, and guess what? They refused. Anyone shocked?

Radio people are just people. If you walked past someone on the street, standing on a soapbox, going on and on to all who would listen about how transgender people are subhuman, what would you do? You would not listen. If everyone did that, the guy would disappear. Well okay, not really. But in the case of these radio guys, they really would. It turns out Jeff Atwood recently wrote a post about the same thing. It's a programming blog but the point is the same. People who rely on media to be heard, whether it's the internet, the radio, or whatever, will disappear if people stop listening to them. What those people need is not money, it's attention. Take that away, and they're no one.

My friend Heather was asking last night, is the internet still there if no one is there to use it? Well, in a sense, no, it's not. A blog that no one reads is a lot like a blog that doesn't exist. (Now you're thinking about posting some clever sarcastic comment involving some form the word "irony." But you're reading this, so shut up.) And a radio host that no one listens to is likely to be fired. So rather than contact the idiots and ask them to apologize, how about we contact the station, and let them know that this kind of shit is just not okay. At all. Ever. (In fact GLAAD succeeded in getting some advertisers to stop advertising on the station. For once I think GLAAD is doing the right thing and all the other orgs are wrong...)

Anyway, if you don't like something that a perfect stranger is doing, ignore them. If everyone did that, the world would be a better place overnight.