XPday London

Conversational Code - Programming Narratives

Submitters: Antony Marcano & Andy Palmer

Level: Intermediate / Advanced

Session Type: Discussion / Dojo

Duration: 90 mins

Target Audience: Programmers; anyone interested in seeing just how expressive code can be

Prerequisites: None, but if you bring code on a laptop that can be plugged into the projector, we'll try to start on the path of being more conversational

 

Code should tell you a story, a story of the world that it is modelling. Or, at least it tells you the programmers understanding of that world at the time they wrote the code. Sometimes that is a literal representation of that world and sometimes it's a metaphorical one.

Too often, code doesn't tell this story. Many 'standard' styles of programming lead good programmers away from incorporating the narrative that they and other programmers will later need to understand the intent behind the code.

We're not just talking about 'clean' code. We're certainly not talking about heavily commented or 'documented' code. We mean that the code itself should be the narrative.

A good story has a beginning, a middle and an end. There is a sense of flow through the story.
A system has a beginning, when it receives input of some kind; a middle, while it is processing; and an end, where the output is sent along.

All too often, this flow is interrupted by convoluted execution paths, ... ,.
It takes time to unpick and understand where the code begins, how it goes through the middle and where it reaches the end.

The goal of Narrative Programming is to make this story arc the centre of the code (and in consequence, the story).

Session Overview:

An interactive session where we'll take code from various sources, including taking code from attendees and, exploring as a group, how to make it more narrative. We'll also share our own code and see if the participants can help us make it more expressive.

Timeline:

  • Intro (5 mins)
  • Facilitated discussion looking at our examples (25 mins)
  • Participants share their code examples and the group suggest refactorings that can make it more expressive. (30 mins)
  • Refactoring from terse code to programming prose dojo (30 mins)

Notes: This session can be reduced to 60 minutes if the code-sharing section is removed and we will use our own examples for the refactoring dojo.

Learning Objectives:

  • What are the advantages of expressive code?
  • Why would we want to change our existing way of working?
  • How can we better communicate our intent to those who were not intimately involved in writing the code?

Comments

From Antony Marcano and Andy Palmer [86.16.245.96] - 2009-09-10

@RobertChatley

With regards to tools, there are no prerequisites, although dynamic languages such as Ruby make this far simpler, so we will be concentrating on Java. The main aim being to show that the verbose nature of Java (or c#) is not a barrier to writing expressive code.

The product of the session is to share our experience that high ceremony languages "force" us to work in a particular way is a myth. We'll know we are done when the time runs out, the participants convince us that we're insane or everyone agrees with us ;-)

Seriously though, we'll be happy if even one person walks away inspired with some new ideas.

 

@Rachel Davies

We have enough canned examples we can work with, although it would be much more fun if we had some code that we weren't familiar with. Particularly as this would put our methods much more in context for the participants

 

@Sallyann Freudenberg and @Seb Rose

We've added timing information and prerequisites to the description

From Sallyann Freudenberg [86.169.28.9] - 2009-09-09

Sorry, the previous comment was me - didn't mean to be anonymous.

From 86.169.28.9 - 2009-09-09

I like the idea of applying a narrative structure to code in this way.

I would like to see a break-down of the timing to show how much time will be discussion and how much practical?  I would also like to know whether there are any pre-requisites for attendees?

From Rachel Davies [212.84.97.237] - 2009-09-03

I like the idea of applying a story arc to code. I think it's unlikely that attendees will bring code along. I suggest that you have some canned examples to work with. I suspect this session will work with a small group.

From RobertChatley [217.155.46.76] - 2009-08-24

I like the sound of this - always in favour of making code more expressive and readable. Will there be a focus on any particular language or tools? Do you expect people to bring laptops? I think a bit of focus would help people to come prepared with appropriate examples and tools.

What do you want the product of the session to be? How will you know when you're done?

From Seb Rose [80.192.119.94] - 2009-08-19

How long would you intend this session to last?

Page

New
Edit
Rename
Versions

Menu

Edit Menu
Versions

Site

Changes
Index
Search
Templates

User

Log In

 
 

Last Modified 2009-09-10