code snippets from the book Head First Design Patterns