Mastering Programming
By Kent Beck, from 2016 but worth a look.
- Concentration. If you need to change several elements, first rearrange the code so the change only needs to happen in one element.
- Isolation. If you only need to change a part of an element, extract that part so the whole subelement changes.
I’ve been refactoring the .replace() operator in Tinderbox. This is straightforward for most attributes but fairly complex when replacing things in text. First, links have to be adjusted if the length of the replacement text differs from the length of the text it replaces. Second, we need to change the styled text as well as the unstyled text. So, there’s a bit of complexity lying about, made worse because Tinderbox shifted its regular expression engine a few years back, and the operator originally ran on the old engine.
See also: Kent Beck.