Code Smells - Summaries
One of the benefits of learning about code smells is you gain a new vocabulary to describe design. This session helps you understand of several of these terms and begin to use a common language with your colleagues.
Learning Goals
- Describe a Code Smell and why this is a useful concept
- Recognize and explain some of the more common code smells
Session Outline
- 5 min connect: Names of Code Smells you know already
- 5 min concept: Martin Fowler’s definition & catalogues
- 5 mins exercise explanation & example: present “Shotgun Surgery”
- 15 mins do: Prepare own presentation
- 15 mins present: Take turns to present a code smell
- 2 min reflect: Note down takeaways
Names of Code Smells you know already
Ask “Do you know any Code Smells? What are they called?” Ask for suggestions and get people to write notes. Read out all the suggestions.
Martin Fowler’s definition & catalogues
Explain the concept of a Code Smell, for example referencing Martin Fowler’s definition. Also show the catalogue of Code Smells on the Samman Society Website.
Exercise - Code Smell presentation preparation
You’d like everyone to work in small groups to prepare a short introduction to a code smell & explain it to another group. Each presentation should include this information:
- How can you detect this smell in your code?
- How would you address or solve this smell?
Demonstrate what you want them to do by giving a 2-3 minute presentation about a code smell, for example “Shotgun Surgery”.
Deal out a different code smell to each group, and give them a time limit of 15 minutes for their preparation. Ask them to look up resources on the internet and perhaps get a Gen AI tool to produce some code with this smell as an illustrative example.
Exercise - Code Smell presentations
Go round and get each group to present the code smell they have prepared. Have a limit of about 3 minutes for each presentation. Try to steer away from longer discussions and make sure there is time for everyone to present.
Conclusions - Note takeaways
Give people a chance to think quietly and write a note for themselves. For example explain the main idea of code smells.