Friday, February 27, 2009

Learning Ruby

After a short distraction with the "new" Gateway PC, I am settling down and doing some serious work with Ruby. Or I should say "serious learning".

I'm building an emulator for the Heathkit H-89 computer, a relic from the pre-PC era. The H-89 used a Z-80 processor and had, at most, 64K of RAM. It also had serial ports, floppy disks, and a few other goodies. By today's standards, it is completely unusable - cell phones have more computing power. Yet for my purposes, the H-89 is a good target: it is simple enough to shoot for, it is complex enough to give me a challenge, and I am familiar with it. (The H-89 was my first real computer.)

My goal is not to build an H-89 emulator but to learn Ruby. The H-89 adds a bit of fun, which is a good thing.

I've set up a rather simple development environment. A few directories, the Ruby interpreter, and Subversion. I have no IDE, no debugger (although there is a Ruby debugger and I will get to it later), and no elaborate requirements documents. I *do* have scripts to run tests.

My configuration allows me to work on a number of things, all at the same time. I have picked a few items from the "smorgasbord" of technologies that I want to learn. With my H-89 project, I can learn:

 - Ruby (the language and its library) and eventually the Ruby debugger

 - Subversion

 - Test-driven development

 - A little bit of bash scripting

 - Object-oriented programming (easy, since I am comfortable with C++, Java, and C#)

 - Refactoring (something I tend to enjoy with other languages)

I am refactoring some code today. I had built a number of modules, with some duplication of code. (Yes, the evil "copy-and-paste" type of re-use.) I an refactoring the code to eliminate the redundant code, and placing the code into classes (it currently lives in global functions). I have identified a number of classes, and as I build each one I start with the test cases for it. My initial analysis was incomplete, though; as I build some classes I identify the need for more classes. I'm OK with finding better designs as I go along -- I don't expect to get the design perfect by simply thinking hard.

No comments:

Post a Comment