[cairo] A gentle request for better commit messages

Mike Shaver mike.shaver at gmail.com
Mon Sep 22 11:13:37 PDT 2008


On Mon, Sep 22, 2008 at 1:59 PM, Ian Osgood <iano at quirkster.com> wrote:
> I completely agree. At previous jobs I'd seen some highly devolved
> internal APIs which festered strings of four or more boolean
> parameters in a row. Boolean parameters are one of those creeping
> features that are best to avoid:
>
> 1. A "flags" parameter with symbolic mask values which may be ORed
> together is easier to read and to extend without breaking ABI.
>
> 2. Sometimes the intent of a boolean parameter is better expressed
> with two different function names. The two functions may then contain
> small amounts of specific code before calling a common function.

I also like using enums for this stuff, since you get some type safety
against illegal values as well.

typedef enum { MOGRIFY_LOTS=0, MOGRIFY_A_LITTLE=1 } cairo_transmogrify_mode_t;
void cairo_transmogrify(cairo_t c, cairo_transmogrify_mode_t mode);

Mike


More information about the cairo mailing list