Appendix J: Source Code Examples
All of the code examples I’ve used in the book are available in my repo on GitHub. So, if you ever want to compare your code against mine, you can take a look at it there.
Each chapter has its own branch named after it, like so:
Be aware that each branch contains all of the commits for that chapter, so its state represents the code at the end of the chapter.
Full List of Links for Each Chapter
Using Git to Check Your Progress
If you feel like developing your Git-Fu a little further, you can add my repo as a remote:
git remote add harry https://github.com/hjwp/book-example.git git fetch harry
And then, to check your difference from the end of [chapter_philosophy_and_refactoring]:
git diff harry/chapter_philosophy_and_refactoring
Git can handle multiple remotes, so you can still do this even if you’re already pushing your code up to GitHub or Bitbucket.
Be aware that the precise order of, say, methods in a class may differ between your version and mine. It may make diffs hard to read.
Downloading a ZIP File for a Chapter
If, for whatever reason, you want to "start from scratch" for a chapter, or skip ahead, and/or you’re just not comfortable with Git, you can download a version of my code as a ZIP file, from URLs following this pattern:
Don’t Let it Become a Crutch!
Try not to sneak a peek at the answers unless you’re really, really stuck. Like I said at the beginning of the last chapter, there’s a lot of value in debugging errors all by yourself, and in real life, there’s no "harrys repo" to check against and find all the answers.