Recording and playing macros
Macros are an extremely powerful tool that allows you to record and replay a set of actions. They’re especially helpful for a certain type of manual task: something too laborious to perform by hand, but not complex enough to warrant a script or a program. There’s a Goldilocks zone for when macros are the most useful, and you’ll get a good feel for when that is.
Here’s a typical example of when a macro would be helpful. An intern tried to author a program that pays homage to Monty Python’s “spam” sketch: almost every meal in the cafe is made with spam! But the intern (of course this wasn’t you!) wrote some no-good code. Just look at the blatant violation of the do-not-repeat-yourself principle:
Figure 6.8 – Some not-so-elegant code demonstrating a repetitive pattern.
The intern’s confusion is understandable: there’s no consistent naming scheme across...