Article Preview
Buy Now
COLUMN
A TemplateString Class
Real-Life Parsing
Issue: 6.2 (January/February 2008)
Author: Charles Yeomans
Author Bio: Charles will be speaking at Real World 2008 on topics other than algorithms.
Article Description: No description available.
Article Length (in bytes): 10,876
Starting Page Number: 36
Article Number: 6215
Related Link(s): None
Excerpt of article text...
Python has a nifty class called Template. Essentially, a Template is a string containing symbols to be replaced by values. After using it in a couple of small Python projects, I decided that a REALbasic version was in order. The result is available from my web site; here, I would like to work through the design and some of the implementation.
Getting Started
The first choice was a class name. "Template" was the obvious choice, but I opted for "TemplateString" instead; it seemed to express the idea of the class a little more explicitly.
I wanted TemplateString objects to be immutable; that is, once created, its public state could not be changed. Such objects are thread-safe, so I would be comfortable keeping static references to them. Immutability would make TemplateString easier to test, and would make it a better fit for the object-functional programming style that I am coming to favor.
...End of Excerpt. Please purchase the magazine to read the full article.