Friday, January 17, 2014

New beginnings

So, I’m starting up yet another blog.  Why?  I don’t really know.  Well, currently it’s called Duan’s Coding Sandbox, but I suspect that for me to continue writing here, it’s going to rapidly have to become Duan’s Odds and Ends.

Anyhow, my immediate impetus for creating this particular post was to start documenting my first faltering steps into the world of Test Driven Development, or TDD.  It was mentioned during some training at work years ago, in a course on unit testing.  The problem was that we were working with a legacy code base where we were bolting the tests on after the fact.  I’ve always wanted to give it a try, but never found myself helming a project from scratch.

So now I’ve found a project of my own.  One of my other interests is language learning, so I’ve decided to whip up a program for helping me do drills.  This lets me build a program from scratch, which I haven’t done in years, and gets me learning something new, in support of one of my other hobbies!  In the past, programming for fun was something I’d do constantly, but soon after getting a job I lost all of that.  Hoping to get it back.

So as I said, my idea is to create a little program.  Currently I want it to do drills: I want the computer to ask me questions, like “What’s the conjugation of this verb?” and then to evaluate my answer.  It’s still a little fuzzy, but I hope it will all become more realized as I work at it.  If not, at least I know this won’t work!

I’ve decided to call the program Ermey, it’s my language learning drill sergeant.  Here’s the list of stuff I’m currently using to bring it to life:

  • Eclipse: Which I am pretty unfamiliar with.  After wrestling with workspaces and working sets and perspectives from a previous attempt at using Eclipse for something, I think I have it in a clean state.  Well, time will tell on that score.
  • Python: 2.7.  Using the PyDev plugin on Eclipse, naturally.  Have only used this for the most basic of things so far but I like it well enough. 
  • Git?: There’s a plugin called EGit for Eclipse.  We have just started using Git for version control at work and it seems complicated and unintuitive right now.  I’m not sure if I should subject myself to the headache.  That said, version control is just good practice.

Anything else will be added as needed.

I’m a TDD noob; I went through Kent Beck’s book a few days ago and got the basics, and now I’m going to try to apply them.  Beck suggests just making a list of the things you need your program to do.  Here’s a first stab at my ideas:

  • Currently, I’m studying two languages, so I’d need the ability to select which language I want to study.  This implies all the rules need to be dynamically loaded, since the rules for one language are not necessarily the same for another.
  • Substitution Drills:  Ermey gives you a verb in the infinitive and a personal pronoun.  You reply with the verb conjugated, and are evaluated.
  • Translation Drill:  Ermey supplies a sentence in one language and you must enter the corresponding in another.
  • Immediately I can think there are other drill types, so they will need to be user defined, likely with some kind of grammar that needs parsing.
  • Store stats (which drills for which words the user gets right)
  • Each word needs to also contain grammatical type information, so that you can be tested on nouns, or verbs, or etc. (and possibly to aid filtering?)

Off the top, I’m thinking of all sorts of designs that could be used under the covers (I just recently started reading the classic Design Patterns book too) but as I understand it, that is against the pure TDD way.  I need to start with the simplest thing possible so I can get the red-green-refactor cycle working.  That said, I’m at a loss where to start.  While I that, I’ll try to get Git up and working.

Current Progress:

Set up the Eclipse environment, created a project, created an empty test.

Next Steps:

  • Figure out smaller steps to get to the bigger one.  My intuition tells me that I want to start by breaking down one of the drills since that’s the core of the interaction.  But I’m tired and will sleep on it.
  • Create the first test case.
  • Get EGit up and running.