« back

Fixing What's Fresh

23 Aug 2012

Sometimes we take our brains for granted. They are not always as efficient as we think they are.

Scenario 1 - "I'll make a mental note."

Last week, I was having trouble with a test.

 1 describe "computer_player" do
 3   let (:board)  { Board.new }
 4   let (:player) { ComputerPlayer.new }
 5   let (:mockai) { MockAi.new(player, board) }
 7   it "should be able to make a move" do
 8     player.set_mark("K")
 9     player.make_move(board)
10     mockai.stub(:find_best_move).and_return(8)
11     board.get(8).should == "K"
12   end
13 end

The reason this is an issue is because I am trying to stub the find_best_move method that I want from the ai class but the ai class is being created in the make_move method. When asking my mentor about this, he pointed me in the direction I needed to head. Since I was working on something else at the time, I made a mental note about and then kept working. When I came back to work on it two days later, I had to go over the code again to remember what I needed to fix. I also didn't exactly remember what my mentor said. What I thought made perfect sense to me at the time was now not so clear. That is a clear waste of time(both his and mine). The time that I had to spend getting reacquainted with my problem could have been spent solving it.

Scenario 2 - "I will change that back after I finish this other thing."

After changing a bunch of code in two spots and then working more closely with one of them,I realized the code needed to be changed back. I changed it back in the one spot and made a mental note to change the other. The next day I ran my tests and something was breaking. Surprise! It was the part of code that I forgot to change back.

I think the best approach will be to "Do it now" as soon as it is an issue. There are plenty of other problems I need my brain's storage for.

comments powered by Disqus