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:

Chapter 1

https://github.com/hjwp/book-example/tree/chapter_01

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

Chapter 1

https://github.com/hjwp/book-example/tree/chapter_01

Chapter 2

https://github.com/hjwp/book-example/tree/chapter_02_unittest

Chapter 3

https://github.com/hjwp/book-example/tree/chapter_unit_test_first_view

Chapter 4

https://github.com/hjwp/book-example/tree/chapter_philosophy_and_refactoring

Chapter 5

https://github.com/hjwp/book-example/tree/chapter_post_and_database

Chapter 6

https://github.com/hjwp/book-example/tree/chapter_explicit_waits_1

Chapter 7

https://github.com/hjwp/book-example/tree/chapter_working_incrementally

Chapter 8

https://github.com/hjwp/book-example/tree/chapter_prettification

Chapter 9

https://github.com/hjwp/book-example/tree/chapter_manual_deployment

Chapter 10

https://github.com/hjwp/book-example/tree/chapter_making_deployment_production_ready

Chapter 11

https://github.com/hjwp/book-example/tree/chapter_automate_deployment_with_fabric

Chapter 12

https://github.com/hjwp/book-example/tree/chapter_organising_test_files

Chapter 13

https://github.com/hjwp/book-example/tree/chapter_database_layer_validation

Chapter 14

https://github.com/hjwp/book-example/tree/chapter_simple_form

Chapter 15

https://github.com/hjwp/book-example/tree/chapter_advanced_forms

Chapter 16

https://github.com/hjwp/book-example/tree/chapter_javascript

Chapter 17

https://github.com/hjwp/book-example/tree/chapter_deploying_validation

Chapter 18

https://github.com/hjwp/book-example/tree/chapter_spiking_custom_auth

Chapter 19

https://github.com/hjwp/book-example/tree/chapter_mocking

Chapter 20

https://github.com/hjwp/book-example/tree/chapter_fixtures_and_wait_decorator

Chapter 21

https://github.com/hjwp/book-example/tree/chapter_server_side_debugging

Chapter 22

https://github.com/hjwp/book-example/tree/chapter_outside_in

Chapter 23

https://github.com/hjwp/book-example/tree/chapter_purist_unit_tests

Chapter 24

https://github.com/hjwp/book-example/tree/chapter_CI

Chapter 25

https://github.com/hjwp/book-example/tree/chapter_page_pattern

Appendix B

https://github.com/hjwp/book-example/tree/appendix_Django_Class-Based_Views

Appendix E

https://github.com/hjwp/book-example/tree/appendix_bdd

Appendix F

https://github.com/hjwp/book-example/tree/appendix_rest_api

Appendix G

https://github.com/hjwp/book-example/tree/appendix_DjangoRestFramework

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 4:

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,1 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:

https://github.com/hjwp/book-example/archive/chapter_01.zip

https://github.com/hjwp/book-example/archive/chapter_philosophy_and_refactoring.zip

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.

1 I don’t recommend skipping ahead. I haven’t designed the chapters to stand on their own; each relies on the previous ones, so it may be more confusing than anything else…