How to display code in a presentation
Software geeks often want to display code in their presentations. However there are a few problems
- Displaying code can be a confusing amount of low level detail when you are really trying to make sure people remember a few key concepts and ideas. You risk your message getting lost as people change gears and attempt to analyse what they are reading.
- The format of the presentation slide does not make is easy to present anything substantial (over 5 statements?) in a coherent fashion. Visual layout, font sizes and a need for consistency make it hard to present much code in single slide
- In some presentation presenting ‘canned’ code looks fake and casts doubt on how genuine it is (e.g. when showing how to write code for a new framework)
What are some of the ways if getting around these issues?
- Don’t use code at all. Refer the audience to examples they can examine later if required
- Split the code into very small pieces (1-5) lines that can be used on a single slide to explain a concept (e.g. how to connect to a specific remote data source). Refer the audience to the complete examples they can examine later if required
- Change the format of the presentation completely for the presentation of more substantial code. This can be done in one of two ways:
- Presenting the material in another program such as a text editor. The editor should be pre-loaded with the code before the presentation starts
- Changing the slide layout to help display code. e.g. remove all background, reduce the font size (carefully), use large margins so that the shorter lines look more natural, change font, change background and font colours to improve contrast
- Type the text direclty into a text editor for demonstration purposes. Not recommended unless you are a very good typist or ‘dummy it’ using a tool such as IO::Prompt
Anyone else have suggestions?



This advice sucks, but I’m too busy writing a talk for Melbourne Perl Mongers tonight to explain why.
May your code always suffer from unbalanced parenthesis!
D’oh, that last comment just makes it look like I’m being rude so the conflict drives up Alec’s traffic.
(See http://pjf.jaiku.com/presence/31336981 )
Realistically, I find that having any line of code that’s longer than about 20 characters ends up being AWFUL. One needs to either split the line, or use a smaller font than I’d like; both are dreadful solutions.
With lines of code that are about 20 characters or less, one can fit a decent amount of code onto a slide and retain readability, sometimes even as much as five lines if the code is simple.
I’m of the opinion that if you’re presenting code that can’t be done in five lines of 20 characters, then the code itself is too hard. One of the reasons I’m so fond of presenting about a module before I release it is to ensure that the API is easy enough to be explained as part of a simple presentation.
and today you were not rude about my post and it did not appear in my stats.
Paul, I only receive validation via your abuse!