Two posts ago I wrote about my struggle with the TurtleCommand
class.
Well, it seems the struggle is over. I’m now in the process of implementing commands, and so far it seems to work fine.
BTW, can you spot a pattern here? Day n, I hit the wall, and have no idea how todo something or why something does not work. Day n+k (for k a small natural number, often 1), everything is up and running.
Interesting.
A reminder to myself: whenever I seem to be unable to solve a problem, perform these simple steps:
Coming back to programming: I decided to go with an inner (i.e., not static) class. The reason was simple: I needed both instances of commands (in retrospect, this is kind of obvious…) and access to fields of the Turtle
class. Of course, this means that the Turtle.java
file started to grow, but I never subscribed to the “one-file-per-class-since-my-editor-cannot-deal-with-large-files-or-what” camp anyway.
Incidentally, it seems that I’ll need no changes outside the Turtle
class! (At least not until I’m going to implement actual new functionality.) Point for you, encapsulation.
And tomorrow, I’m going to publish an overdue post about the clear-screen feature (the post is ready, but I decided not to publish more than one per day). It seems that the app is slowly maturing – though I have quite a few ideas left to explore!