Code patterns for chapter 6