Prefer enum types to Boolean for function parameters. Limit the use of the Boolean type to function return types.

The reason is because when you have a function call such as:

 package.Configure( handleBlock, userContext, true );

the reader has no idea what ‘true’ means. If the third parameter were of type enum, such as:

enum ConfigureExisting

then the client call is more legible:

 package.Configure( handleBlock, userContext, doConfigureExisting );

This page is an example of Catching defects with Patterns.

Community content is available under CC-BY-SA unless otherwise noted.