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?
|