Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 6.2

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.