in reply to Using Templates
Unless I am actually processing millions of files, I care very little for what is thought to be “most efficient.” But I always care very much for what is“cleanest to read.”
A very good rule of thumb for this is, “separation of concerns.” In the code-snippet you show us, it is hard to immediately see how “input processing and preparation” is cleanly separated from “templating and output.” But if you look at the later reply which shows the use of a templating-engine, it is much more clear. That’s because the template describes what data is used and how that data is formed into an output string. I’m really not terribly concerned which templating system you use.
I am also keenly sensitive to, “how maintainable will this thing be?” When (not “if”) a change is needed, how quickly and confidently can a total stranger make that change? How likely is it that an “isolated” change to one aspect of the software will have not-isolated (i.e. “suh-prize! it’s two o’clock in the morning and your beeper’s going off...”) consequences?