I worked on my "macron" macro processor today. This is a program written in Ruby, and it has two purposes. The first is to convert text into XML files and provide closing tags at the proper place. The second is to let me improve my knowledge of Ruby.
I focussed on the second purpose today. I had two sections of code that read macro definitions from a file. (My initial design of the program was sloppy.) Today I refactored the program to use a single section of code. The adjustment used bits of both old sections of code, combining them into a single function.
I'm pleased with the result. The code is smaller (from 270 lines to 235 lines) and easier to read. Also, the code is more robust; the two old sections of code each had their specific functions but neither did everything. Now the logic is complete and in a single place.
I used automated tests during the refactoring effort. They helped immensely. At the end of the day, I knew that I had all functionality working.
The program is not perfect, nor complete. I have more features to add, and a few tests to add. But for today, it's good progress.
No comments:
Post a Comment