- Time: 5-10 minutes
Put a code snippet up on the shared screen and ask a question about it. Give people time to read the code in order to answer the question.
The code sample should be short and as easy to read as you can manage. It should make the answer to the question as obvious as possible. The answer to the question should lead people to think about a computer science or programming concept that you expect them to be familiar with, but not necessarily know the name of. Something like
- what’s wrong with this code?
- what result would this code return?
- Is the name of this method accurate?
Follow up with “what is the official name of this code smell/design pattern/programming concept?”
You’re trying to connect with their previous knowledge of this topic and help them remember the name of it.
For example the code could show poor encapsulation, poor choice of names, duplication, or any other code smell. Alternatively the code could be a well-designed textbook example of a design pattern like Singleton or computer science concept like polymorphism, delegation, Last-In-First-Out etc.
Quite often people know about concepts in practice but not in theory. By showing them some actual code that exhibits a design flaw or exemplifies a particular computer science concept, you help people to access what they know, even if they can’t express the official name for it.