Skip to content

Commit 17beeaa

Browse files
committed
Merge remote-tracking branch 'atlas/main'
2 parents 6fc6c1b + 39813d5 commit 17beeaa

File tree

339 files changed

+266
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

339 files changed

+266
-99
lines changed

ai_preface.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ and undecipherable spaghetti code that spells a maintenance nightmare.
3535
=== Mitigations for AI's Shortcomings Sure Look A Lot Like TDD
3636

3737
If you read the advice, even from AI companies themselves,
38-
about the best way to work with AI, you'll find date that it
38+
about the best way to work with AI, you'll find that it
3939
performs best when working in small, well-defined contexts,
4040
with frequent checks for correctness.
4141
When taking on larger tasks, the advice is to break them down into smaller,

appendix_IX_cheat_sheet.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Relevant chapters:
5656

5757
[[Double-Loop-TDD-diagram2]]
5858
.Double-loop TDD
59-
image::images/double-loop-tdd-simpler.png["An inner red/green/refactor loop surrounded by an outer red/green of FTs"]
59+
image::images/tdd3_0405.png["An inner red/green/refactor loop surrounded by an outer red/green of FTs"]
6060

6161

6262
Relevant chapters:

atlas.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@
4343
"chapter_26_page_pattern.asciidoc",
4444
"chapter_27_hot_lava.asciidoc",
4545
"epilogue.asciidoc",
46+
"bibliography.asciidoc",
4647
"appendix_IX_cheat_sheet.asciidoc",
4748
"appendix_X_what_to_do_next.asciidoc",
48-
"appendix_github_links.asciidoc",
49+
"appendix_github_links.asciidoc",
4950
"ix.html",
5051
"author_bio.html",
5152
"colo.html"
@@ -92,4 +93,4 @@
9293
"lang": "en",
9394
"accent_color": "",
9495
"preprocessing": "none"
95-
}
96+
}

bibliography.asciidoc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
A few books about TDD and software development that I've mentioned in the book,
77
and which I enthusiastically recommend.
88

9-
* Kent Beck, _Test Driven Development: By Example_, Addison-Wesley
10-
* Martin Fowler, _Refactoring_, Addison-Wesley
11-
* Ross Anderson, _Security Engineering, Third Edition_, Addison-Wesley: https://www.cl.cam.ac.uk/archive/rja14/book.html
12-
* Steve Freeman and Nat Pryce, _Growing Object-Oriented Software Guided by Tests_, Addison-Wesley
13-
* Hal Abelson, Jerry Sussman and Julie Sussman, _Structure and Interpretation of Computer Programs_ (SICP), MIT Press
14-
* Dave Farley, _Modern Software Engineering_, Addison-Wesley
9+
++++
10+
<ul class="simplelist">
11+
<li>Kent Beck, <em>Test Driven Development: By Example</em>, Addison-Wesley</li>
12+
<li>Martin Fowler, <em>Refactoring_, Addison-Wesley</em></li>
13+
<li>Ross Anderson, <em>Security Engineering, Third Edition</em>, Addison-Wesley: https://www.cl.cam.ac.uk/archive/rja14/book.html</li>
14+
<li id="GOOSGBT">Steve Freeman and Nat Pryce, <em>Growing Object-Oriented Software Guided by Tests</em>, Addison-Wesley</li>
15+
<li>Hal Abelson, Jerry Sussman and Julie Sussman, <em>Structure and Interpretation of Computer Programs</em> (SICP), MIT Press</li>
16+
<li>Dave Farley, <em>Modern Software Engineering</em>, Addison-Wesley</li>
17+
</ul>
18+
++++

chapter_01.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ That's why they seldom fall off things, see, no matter how steep they are.
5151
As you can see in <<tree_goat>>.
5252
[[tree_goat]]
5353
.Goats are more agile than you think (source: http://www.flickr.com/photos/caitlinstewart/2846642630/[Caitlin Stewart, on Flickr])
54-
image::images/twp2_0101.png["A picture of a goat up a tree", scale="50"]
54+
image::images/tdd3_0101.png["A picture of a goat up a tree", scale="50"]
5555

5656

5757
We'll proceed with nice small steps;
@@ -150,7 +150,7 @@ you might encounter a strange popup window, such as the one shown in <<firefox_u
150150
151151
[[firefox_upgrade_popup]]
152152
.Firefox Wants to Install a New What Now?
153-
image::images/firefox_upgrade_popup.png["A popup window saying 'Firefox is trying to install a new helper tool.' and prompting for a username and password"]
153+
image::images/tdd3_0102.png["A popup window saying 'Firefox is trying to install a new helper tool.' and prompting for a username and password"]
154154
155155
This happens when Firefox has automatically downloaded a new version,
156156
in the background.
@@ -277,7 +277,7 @@ back in the original shell, using Ctrl-C.
277277

278278
[[installed_successfully_screenshot]]
279279
.It worked!
280-
image::images/twp2_0102.png["Screenshot of Django Installed Successfully Screen"]
280+
image::images/tdd3_0103.png["Screenshot of Django Installed Successfully Screen"]
281281

282282

283283
.Adieu to Roman Numerals!
@@ -505,7 +505,7 @@ PS - to quit vim, it's Esc, then `:q!`]
505505

506506
[[first_git_commit]]
507507
.First Git commit
508-
image::images/twp2_0103.png["Screenshot of git commit vi window"]
508+
image::images/tdd3_0104.png["Screenshot of git commit vi window"]
509509

510510

511511
NOTE: If you want to really go to town on Git,

chapter_04_philosophy_and_refactoring.asciidoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ That way you don't have to be smart _all_ the time.
5959

6060
[[figure4-1]]
6161
.Test ALL the things (original illustration source: http://bit.ly/1iXxdYp[Allie Brosh, Hyperbole and a Half])
62-
image::images/twp2_0401.png["Test ALL the things",float="right"]
62+
image::images/tdd3_0401.png["Test ALL the things",float="right"]
6363

6464

6565
OK, perhaps _in general_, you're prepared to concede that TDD is a good
@@ -785,7 +785,7 @@ stick to small steps; keep refactoring and functionality changes entirely separa
785785

786786
[[RefactoringCat]]
787787
.Refactoring Cat--be sure to look up the full animated GIF (source: 4GIFs.com)
788-
image::images/twp2_0402.png["An adventurous cat, trying to refactor its way out of a slippery bathtub"]
788+
image::images/tdd3_0402.png["An adventurous cat, trying to refactor its way out of a slippery bathtub"]
789789

790790

791791
NOTE: We'll come across "Refactoring Cat" again during this book,
@@ -990,14 +990,14 @@ See <<simple-tdd-diagram>>.
990990

991991
[[simple-tdd-diagram]]
992992
.TDD process as a flowchart, including the unit test / code cycle
993-
image::images/tdd-process-unit-tests-only-excalidraw.png["A flowchart with boxes for tests, coding and refactoring, with yes/no labels showing when we move forwards or backwards"]
993+
image::images/tdd3_0403.png["A flowchart with boxes for tests, coding and refactoring, with yes/no labels showing when we move forwards or backwards"]
994994

995995
It's very common to talk about this process using the three words
996996
_Red, Green, Refactor_. See <<red-green-refactor>>.
997997

998998
[[red-green-refactor]]
999999
.Red, Green, Refactor
1000-
image::images/red-green-refactor-excalidraw.png["Red, Green and Refactor as three nodes in a circle, with arrows flowing around."]
1000+
image::images/tdd3_0404.png["Red, Green and Refactor as three nodes in a circle, with arrows flowing around."]
10011001

10021002
* We write a test, and see it fail ("Red").
10031003
* We cycle between code and tests until the test passes: "Green".
@@ -1013,7 +1013,7 @@ with an inner red/green/refactor loop being required to get an FT from Red to Gr
10131013

10141014
[[double-loop-tdd-diagram]]
10151015
.Double-Loop TDD: Inner and Outer Loops
1016-
image::images/double-loop-tdd-simpler.png["An inner red/green/refactor loop surrounded by an outer red/green of FTs"]
1016+
image::images/tdd3_0702.png["An inner red/green/refactor loop surrounded by an outer red/green of FTs"]
10171017

10181018
When a new feature or business requirement comes along,
10191019
we write a new (failing) FT to capture a high level view of the requirement.

chapter_05_post_and_database.asciidoc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ you should see a page that looks like
332332

333333
[[csrf_error_screenshot]]
334334
.Django DEBUG page showing CSRF error
335-
image::images/twp2_0501.png["Django DEBUG page showing CSRF error"]
335+
image::images/tdd3_0501.png["Django DEBUG page showing CSRF error"]
336336

337337

338338
.Security: Surprisingly Fun!
@@ -537,7 +537,7 @@ you'll see something like <<table_gone_screenshot>>.
537537

538538
[[table_gone_screenshot]]
539539
.I see my item text but no table...
540-
image::images/todo_list_table_disappeared.png["A screenshot of the page after submission, which just has the raw text You submitted: Buy asparagus"]
540+
image::images/tdd3_0502.png["A screenshot of the page after submission, which just has the raw text You submitted: Buy asparagus"]
541541

542542
What we really want to do is add the POST submission
543543
to the todo items table in the home page template.
@@ -1366,6 +1366,7 @@ or it may be an indication that the thing you're testing is too complicated.
13661366
Let's add that to a little to-do list of our own,
13671367
perhaps on a piece of scrap paper:
13681368

1369+
13691370
[role="scratchpad"]
13701371
*****
13711372
* 'Code smell: POST test is too long?'
@@ -1516,6 +1517,7 @@ I've added a couple of the other things that are on our mind:
15161517
* 'Support more than one list!'
15171518
*****
15181519

1520+
15191521
Let's start with the first scratch pad item:
15201522
_Don't save blank items for every request_.
15211523
We could tack on an assertion to an existing test,
@@ -1702,6 +1704,7 @@ def home_page(request):
17021704
It's actually closely related to "Display multiple items",
17031705
so we'll put it just before that one:
17041706

1707+
17051708
[role="scratchpad"]
17061709
*****
17071710
* '[strikethrough line-through]#Don't save blank items for every request#'
@@ -1711,6 +1714,7 @@ def home_page(request):
17111714
* 'Support more than one list!'
17121715
*****
17131716

1717+
17141718
And here's the refactored version of _views.py_ using the `.objects.create()`
17151719
helper method that Django provides, for one-line creation of objects:
17161720

@@ -1793,6 +1797,7 @@ Much better! Back to our to-do list:
17931797
* 'Support more than one list!'
17941798
*****
17951799

1800+
17961801
Crossing things off the list is almost as satisfying as seeing tests pass!
17971802

17981803
The third and fourth items are the last of the "easy" ones.
@@ -1946,7 +1951,7 @@ as in <<operationalerror>>.
19461951
[[operationalerror]]
19471952
[role="width-75"]
19481953
.Another helpful debug message
1949-
image::images/django_operationalerror.png["Screenshot of Django debug page, saying OperationalError at / no such table: lists_item"]
1954+
image::images/tdd3_0503.png["Screenshot of Django debug page, saying OperationalError at / no such table: lists_item"]
19501955

19511956

19521957
[role="pagebreak-before less_space"]
@@ -2074,7 +2079,7 @@ But, as it's running, you may notice something is amiss, like in
20742079

20752080
[[items_left_over_from_previous_run]]
20762081
.There are list items left over from the last run of the test
2077-
image::images/twp2_0503.png["There are list items left over from the last run of the test"]
2082+
image::images/tdd3_0504.png["There are list items left over from the last run of the test"]
20782083

20792084

20802085
Oh dear. It looks like previous runs of the test are leaving stuff lying around
@@ -2157,6 +2162,7 @@ adding support for more than one list.
21572162
* 'Support more than one list!'
21582163
*****
21592164

2165+
21602166
I mean, we _could_ ship the site as it is, but people might find it strange
21612167
that the entire human population has to share a single to-do list.
21622168
I suppose it might get people to stop and think about

chapter_06_explicit_waits_1.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ they seem a bit unscientific, so we'll replace them with something more reliable
2323
* _Remove time.sleeps_
2424
*****
2525

26+
2627
Both of these changes will be moving us towards testing "best practices",
2728
making our tests more deterministic and more reliable.
2829

chapter_07_working_incrementally.asciidoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Something like <<multiple-lists-users-and-urls>>:
7373

7474
[[multiple-lists-users-and-urls]]
7575
.Multiple users with multiple lists at multiple URLs
76-
image::images/multiple-lists-users-and-urls.png["An illustration showing two users looking at two different lists with different items, at different URLs."]
76+
image::images/tdd3_0701.png["An illustration showing two users looking at two different lists with different items, at different URLs."]
7777

7878

7979
==== YAGNI!
@@ -162,6 +162,7 @@ Apart from anything else, you can't use PUT in a standard HTML form.)
162162
((("", startref="MLTsmall07")))
163163
In summary, our scratchpad for this chapter looks something like this:
164164

165+
165166
[role="scratchpad"]
166167
*****
167168
* _Adjust model so that items are associated with different lists_
@@ -171,7 +172,6 @@ In summary, our scratchpad for this chapter looks something like this:
171172
*****
172173

173174

174-
175175
=== Implementing the New Design Incrementally Using TDD
176176

177177
((("Test-Driven Development (TDD)", "overall process of")))
@@ -198,7 +198,7 @@ we _don't_ touch to help make sure we don't break anything in the process.
198198

199199
[[double-loop-tdd-diagram-2]]
200200
.The TDD Process With Both Functional and Unit Tests
201-
image::images/double-loop-tdd-simpler.png["An inner red/green/refactor loop surrounded by an outer red/green of FTs"]
201+
image::images/tdd3_1708.png["An inner red/green/refactor loop surrounded by an outer red/green of FTs"]
202202

203203

204204
[role="pagebreak-before less_space"]
@@ -1279,6 +1279,7 @@ Where are we with our own to-do list?
12791279
* 'Add URLs for adding a new item to an existing list via POST'
12801280
*****
12811281

1282+
12821283
We've _sort of_ made progress on the second item,
12831284
even if there's still only one list in the world.
12841285
The first item is a bit scary.
@@ -1562,7 +1563,7 @@ and click around to see what's going on.
15621563

15631564
[[post-in-dev-tools]]
15641565
.Dev Tools Shows a POST Request to /
1565-
image::images/devtools-post-request.png["screenshot of browser dev tools with a POST request in the network tab, with the File column showing /"]
1566+
image::images/tdd3_0703.png["screenshot of browser dev tools with a POST request in the network tab, with the File column showing /"]
15661567

15671568

15681569
Actually _both_ our forms are still pointing to the old URL.
@@ -1671,7 +1672,6 @@ And we can cross out an item on the to-do list:
16711672
* 'Add URLs for adding a new item to an existing list via POST'
16721673
*****
16731674

1674-
16751675
=== Biting the Bullet: Adjusting Our Models
16761676

16771677
Enough housekeeping with our URLs.

chapter_08_prettification.asciidoc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ It's a bit like testing a constant, in that tests usually wouldn't add any value
5959

6060
[[homepage-looking-ugly]]
6161
.Our home page, looking a little ugly...
62-
image::images/ugly-homepage.png["Our home page, looking a little ugly."]
62+
image::images/tdd3_0801.png["Our home page, looking a little ugly."]
6363

6464

6565
((("static files", "challenges of")))
@@ -736,7 +736,7 @@ as in <<list-page-centered>>.
736736

737737
[[list-page-centered]]
738738
.Our site starts to look a little better...
739-
image::images/prettified-1.png["The list page with centered header."]
739+
image::images/tdd3_0802.png["The list page with centered header."]
740740

741741

742742

@@ -842,7 +842,7 @@ That ends up looking something like <<jumbotron-header>>:
842842

843843
[[jumbotron-header]]
844844
.A big grey box at the top of the page
845-
image::images/prettified-2.png["The homepage with a big grey box surrounding the title and input"]
845+
image::images/tdd3_0803.png["The homepage with a big grey box surrounding the title and input"]
846846

847847

848848
TIP: When hacking about with design and layout,
@@ -919,7 +919,7 @@ I think that looks great!
919919

920920
[[dark-modeee]]
921921
.Dark Modeeeeeeeeee
922-
image::images/prettified-dark.png["Screenshot of lists page in dark mode. Cool."]
922+
image::images/tdd3_0804.png["Screenshot of lists page in dark mode. Cool."]
923923

924924

925925
But it's very much a matter of personal preference,
@@ -936,7 +936,7 @@ Getting it into shape took me a few goes, but I'm reasonably happy with it now
936936

937937
[[homepage-looking-better]]
938938
.The lists page, looking... good enough for now.
939-
image::images/prettified-final.png["Screenshot of lists page in light mode with decent styling."]
939+
image::images/tdd3_0805.png["Screenshot of lists page in light mode with decent styling."]
940940

941941
If you want to go further with customising Bootstrap,
942942
you need to get into compiling Sass.
@@ -982,6 +982,7 @@ Oh woops, we nearly forgot our scratchpad:
982982
* _Find a better way to unit test form+input elements_
983983
*****
984984

985+
985986
When working on layout and styling, you expect to spend most of your time
986987
in the browser, in a cycle of tweaking your HTML and hitting "refresh" to see
987988
the effects, with occasional runs of your layout FT, if you have one.

0 commit comments

Comments
 (0)