One of the most important reality checks I use to evaluate material I'm thinking about publishing is to use it in a training setting. Present a prospective guideline to a gaggle of professional C++ software developers, and you find out pretty quickly whether it comprises useful and practical advice. A prospective guideline I have for
Effective C++11 is
Declare overriding functions override
.
I've drafted training slides for this guideline, and I'd like you to take a look and let me know what you think. (Links are at the end of this post.)
I don't normally ask for public feedback on material in the form of training slides, but in this case, I'd like to know what you think about some formatting decisions I'm in the process of making. I don't want to put a lot of effort into a manuscript only to find out later that I botched my choice of formatting options.
For over a decade, I've used a proportional font for my code examples.
Such a font uses differing widths for different characters. An "m" is
much wider than an "i", for example. This has the advantage that I can
get a lot more characters on a line, which is important when I'm trying
to shoehorn commented code into pages or columns of relatively narrow
width. It has the disadvantage that most programmers use a fixed-pitch
font (one where all the characters are the same width), so the code I
publish doesn't look like what they see in their daily work. In
the example I'm making available, I'm using a fixed-pitch font, e.g.:
In a proportional font, it would look like this:
For a more extensive example of code in a proportional font, take a look at my C++11 training materials sample.
Question #1: Do you have a preference which is used in the technical material you read?
Whenever I've had multiple colors for code at my disposal, I've used blue for "normal" code and red as a highlight color (see "const" in the code examples above). Setting aside the specific color choices (which have drawbacks, both for color-blind readers and when printed on monochrome printers), the key point is that I've used two colors for code. An obvious alternative is use multiple colors to syntax-highlight the code, then find another means to highlight important sections. One approach is to mimic highlighting pens by using yellow as a background color. This is what was done with
my Universal References article at isocpp.org:
Another approach is to use bold face to indicate highlighted code sections. Here's that approach applied to the first code fragment I showed above:
Question #2: What approach to code coloring do you prefer?
- One color for "normal" code, a second color for highlighted code.
- Syntax-colored code with yellow highlighting.
- Syntax-colored code with bold highlighting.
It's hard to form an opinion without more than the tiny code fragments I've used in this blog post, of course, so please take a look at my draft Item for "Declare overriding functions
override
." It's available in two versions:
I realize that's not all possible combinations of choices, but putting together the various combinations is more work than you might imagine. That's why I've provided links to other examples where I've used different combinations of choices.
Please let me know what you think about the formatting choices I've described. Of course, I welcome comments on the technical content, too :-)
Thanks for your help with this.
Scott