Declare overriding functionsI'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.:
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.
override." It's available in two versions:
- Fixed-pitch code font, blue "normal" code, red highlighted code.
- Fixed-pitch code font, syntax-colored code, bold highlighted code.
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.