Tinker tinker tinker

I’m refactoring the knit grapher right now. “Refactoring” is a fancy-schmancy programmer term for “re-writing”. I’m installing the groovy XML-based stitch definitions that I came up with a few weeks back.

I’m not sure if the graphing instructions are going to work. We’ll see.

update

Okay, I’ve worked the new stitch objects into the parsing half of the code.
The cable grapher is divided pretty equally into two parts: a parser which reads in the text pattern and figures out what stitches it represents, and a grapher which draws those stitches on a graph.

As I write the code, I’m using test-driven development, which means that before I add a new function I create a test to make sure that function is working correctly. When the test passes, I know that the function works. This also means that as I go back and re-factor the code, I can keep running all the tests to make sure I haven’t broken anything.

The new stitch objects that I’m defining in XML are meant to replace code in both halves of the existing system. They contain the name of the stitch, the abbreviation that will be used in the text directions, and the directions for drawing the stitch in a graph. What I’ve done so far is to rip out some objects in the parser side and replace them with the new stitch objects. Since I’ve already got all the tests in place, I know that as of about half and hour ago, everything is still working correctly. Now I just need to insert the new objects into the graphing side of things and I’ll have a program that’s easier to maintain and smaller than the first version.

And that’s a Good Thing™.

update
Fundamental flaw with my new stitch object design: the directions for drawing out the various stitches are too complex to code as a single string, which is what I’ve been trying to do.

No problem. Instead of encoding the directions, I’m going to create a sample image and encode that. Unfortunately my XML is pretty weak; I’m not sure how to encode anything except text. I’d like to store the images as binary strings; we’ll see if I can figure out how to do that.

No Responses to “Tinker tinker tinker”

  1. David Says:

    Sorry, I should have marked this post Geek Alert. :-)

  2. Georgina Says:

    Huh?

  3. Jon Says:

    You might want to check out Sheila’s blog at http://www.nwkniterati.com/movabletype/blog/ as she is working on a program to do virtual swatches and may have some interesting knowledge to share…

  4. cari Says:

    Did you hear that? That was the sound of my eyes glazing over. 😉

    Is this what the inside of your brain looks like?