next up previous contents
Next: Make it portable Up: General style Previous: Loading other files

Make it robust

We consider it good practice, when writing packages and classes, to use LATEX commands as much as possible.

Thus, instead of using \def... we recommend using one of \newcommand, \renewcommand or \providecommand; \CheckCommand is also useful. Doing this makes it less likely that you will inadvertently redefine a command, giving unexpected results. When you define an environment, use \newenvironment or \renewenvironment instead \def\foo{...} and \def\endfoo{...}. If you need to set or change the value of a <dimen> or <skip> register, use \setlength. To manipulate boxes, use LATEX commands such as \sbox, \mbox and \parbox rather than \setbox, \hbox and \vbox. Use \PackageError, \PackageWarning or \PackageInfo (or the equivalent class commands) rather than \@latexerr, \@warning or \wlog. It is still possible to declare options by defining \ds@<option> and calling \@options; but we recommend the \DeclareOption and \ProcessOptions commands instead. These are more powerful and use less memory. So rather than using:

   \def\ds@draft{\overfullrule 5pt}
   \@options
you should use:
   \DeclareOption{draft}{\setlength{\overfullrule}{5pt}}
   \ProcessOptions\relax

The advantage of this kind of practice is that your code is more readable and, more important, that it is less likely to break when used with future versions of LATEX.


next up previous contents
Next: Make it portable Up: General style Previous: Loading other files
LaTeX3 Mail Server
1999-07-12