The third major curse of computer programming is backward compatibility. You have to fix bugs which will unavoidably be found. Some syntax is not really a good idea, and has to be modified to be less bad. These modifications are evil. Either you fix the bug and the behavior of a command changes, or you keep the bug to ensure backward compatibility. The first possibility can have dramatic consequences, e.g. when you use latex to manage your hotel and that \removeClient
is modified so instead of removing a patient from the database, it sends a robot to actually remove him from the room, and you tex an old file. The second one leaves you with a \removeClient
macro along with a \deleteClient
macro, and you never know which one does what you want.
This problem is especially acute in latex, where you are always hacking around suspicious behaviors to get what \expandafter\noexpand\noexpand\noexpand you want : a bug correction can wreck your document at the worse time.
I noticed that several packages deal with this kind of problem by providing a compatibility command. For example, pgfplots
has \pgfplotsset{compat=1.7}
, siunitx
has a version-1-compatibility
option, mhchem
is invoked with \usepackage[version=3]{mhchem}
. Other strategies include designing your package correctly from the beginning and, in the rare cases where a drastic change is needed, well, you can afford both \pgfdeclarearrow
and \pgfarrowsdeclare
. Alternatively, not caring at all about the problem is an option.
From the point of view of an user, the first solution is extremely convenient, as you don't have to find old versions of the packages and fight to get it to work. My question is, how does this work from the point of view of the latex package author ?
Is it better to have conditionals inside your main code, or is it better to have some compatibility files, loaded when compatibility is sought, that contain the compatible definitions of the relevant macros, which supersede the regular ones ? Or are there other solutions ? And how much difficult it is to maintain a latex code base where you want to take such measures ?
All in all, what are best practices when dealing with backward compatibility in latex ?
\removeClient
sends a robot to execute the guest rather than deleting an entry from the database, then maintaining backward compatibility would seem less than desirable.