My Apprenticeship - Wednesday, August 4, 2004

This summer I'm revisiting my short apprenticeship at Object Mentor. I'll be posting commentary on all my posts from the summer of 2004 exactly 5 years later to the day.

Wednesday 8-4-04

Good news! With Jet Brains' 'Resharper' plug-in installed, Visual Studio is way more fun. Not as cool as IntelliJ, but it's getting there. As you might have guessed, the TDD and Refactoring class is being taught in C#. The first day was weird for me: I realized that a few months ago I would have been way overwhelmed but now I was following along with ease. I wasn't some sort of huge revelation, it's just that while James was writing a bunch of UML on the board I not only didn't have that sinking feeling UML used to inspire but I knew what pattern he was going for before he finished. Cool. The course is shaping up like this: Basic refactoring and Unit tests today, tomorrow should be test-first programming with refactoring (always with refactoring), and I suspect we will get into FitNesse late tomorrow or Friday.

A few minutes ago I finished up my TDD re-write of Tic Tac Toe and I'm including a zipped version of the source code here (tests are included, of course) [Future Jake note: the files can be found on Github at http://github.com/jscruggs/tic-tac-toe/tree/master in the third_pass_tdd directory]. Feel free to open it up, run the tests, and give me some feedback. It's a text-based game so don't expect a gui or anything fancy. I use a minimax algorithm to make the computer choose the best move. If you want to know more about my history with the Tic Tac Toe program, you should look at my may 2004 post.

How do I feel about writing TTT test-first verses without-a-net? I gotta say that the tests make everything more sane. With TDD, I could focus on one problem at a time without having to be driven crazy by weird bugs and mountains of suspect code. During my first non-test version of minimax I had this bug where when I asked the computer to move it filled in all 9 of the spaces. I spent days staring at code before I realized that I was passing a reference to the board instead of a value (so the board got changed as the computer tried checked of the possible moves). Of course I didn't find this bug until I had written enough code to make it run, so I was stuck looking at everything. When I wrote the minimax test-first, I focused on just the minimax method and the test. That's it ' any problems had to be somewhere in those lines of code. Which made it lots easier.

Now you may object that having written TTT once, it was easier to write it a second time. Yes, but when I re-wrote TTT in Python, without tests, I still had tons of problems with bugs (see blog entries 6-14-04 through 6-17-04).

Once again I have posted my early bad code to github so you can see it in all its splendor. And that action gets at one of the reasons I'm re-visiting these posts: To point out that everyone came from somewhere. When I was getting started in teaching and programing I often made the mistake of lionizing those above me (without even thinking about it) instead of realizing that they were just people like me who hard worked hard to get better.

Comments

Popular posts from this blog

Point Inside a Polygon in Ruby

What's a Good Flog Score?

SICP Wasn’t Written for You