Skip to content

Commit 30e4fa1

Browse files
committed
update book from master
1 parent 74c9542 commit 30e4fa1

24 files changed

+1395
-550
lines changed

book/appendix_csvs.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@
131131
<h2 id="appendix_csvs">Appendix C: Swapping Out the Infrastructure: Do Everything with CSVs</h2>
132132
<div class="sectionbody">
133133
<div class="paragraph">
134-
<p>This appendix is intended as a little illustration of the benefits of the
134+
<p>
135+
This appendix is intended as a little illustration of the benefits of the
135136
Repository, Unit of Work, and Service Layer patterns. It&#8217;s intended to
136137
follow from <a href="/book/chapter_06_uow.html">[chapter_06_uow]</a>.</p>
137138
</div>
@@ -310,7 +311,8 @@ <h2 id="appendix_csvs">Appendix C: Swapping Out the Infrastructure: Do Everythin
310311
<div class="sect2">
311312
<h3 id="_implementing_a_repository_and_unit_of_work_for_csvs">Implementing a Repository and Unit of Work for CSVs</h3>
312313
<div class="paragraph">
313-
<p>Here&#8217;s what a CSV-based repository could look like. It abstracts away all the
314+
<p>
315+
Here&#8217;s what a CSV-based repository could look like. It abstracts away all the
314316
logic for reading CSVs from disk, including the fact that it has to read <em>two
315317
different CSVs</em> (one for batches and one for allocations), and it gives us just
316318
the familiar <code>.list()</code> API, which provides the illusion of an in-memory
@@ -366,7 +368,8 @@ <h3 id="_implementing_a_repository_and_unit_of_work_for_csvs">Implementing a Rep
366368
</div>
367369
</div>
368370
<div class="paragraph">
369-
<p>And here&#8217;s what a UoW for CSVs would look like:</p>
371+
<p>
372+
And here&#8217;s what a UoW for CSVs would look like:</p>
370373
</div>
371374
<div id="csvs_uow" class="exampleblock">
372375
<div class="title">A UoW for CSVs: commit = csv.writer (src/allocation/service_layer/csv_uow.py)</div>
@@ -419,7 +422,8 @@ <h3 id="_implementing_a_repository_and_unit_of_work_for_csvs">Implementing a Rep
419422
</div>
420423
</div>
421424
<div class="paragraph">
422-
<p>Ta-da! <em>Now are y&#8217;all impressed or what</em>?</p>
425+
<p>
426+
Ta-da! <em>Now are y&#8217;all impressed or what</em>?</p>
423427
</div>
424428
<div class="paragraph">
425429
<p>Much love,</p>
@@ -438,7 +442,7 @@ <h3 id="_implementing_a_repository_and_unit_of_work_for_csvs">Implementing a Rep
438442
</div>
439443
<div id="footer">
440444
<div id="footer-text">
441-
Last updated 2020-03-17 09:07:44 UTC
445+
Last updated 2020-03-20 13:47:19 UTC
442446
</div>
443447
</div>
444448
<style>

book/appendix_django.html

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@
131131
<h2 id="appendix_django">Appendix D: Repository and Unit of Work Patterns with Django</h2>
132132
<div class="sectionbody">
133133
<div class="paragraph">
134-
<p>Suppose you wanted to use Django instead of SQLAlchemy and Flask. How
134+
<p>
135+
136+
Suppose you wanted to use Django instead of SQLAlchemy and Flask. How
135137
might things look? The first thing is to choose where to install it. We put it in a separate
136138
package next to our main allocation code:</p>
137139
</div>
@@ -197,7 +199,10 @@ <h2 id="appendix_django">Appendix D: Repository and Unit of Work Patterns with D
197199
<div class="sect2">
198200
<h3 id="_repository_pattern_with_django">Repository Pattern with Django</h3>
199201
<div class="paragraph">
200-
<p>We used a plug-in called
202+
<p>
203+
204+
205+
We used a plugin called
201206
<a href="https://github.com/pytest-dev/pytest-django"><code>pytest-django</code></a> to help with test
202207
database management.</p>
203208
</div>
@@ -299,7 +304,9 @@ <h3 id="_repository_pattern_with_django">Repository Pattern with Django</h3>
299304
<div class="sect3">
300305
<h4 id="_custom_methods_on_django_orm_classes_to_translate_tofrom_our_domain_model">Custom Methods on Django ORM Classes to Translate to/from Our Domain Model</h4>
301306
<div class="paragraph">
302-
<p>Those custom methods look something like this:</p>
307+
<p>
308+
309+
Those custom methods look something like this:</p>
303310
</div>
304311
<div id="django_models" class="exampleblock">
305312
<div class="title">Django ORM with custom methods for domain model conversion (src/djangoproject/alloc/models.py)</div>
@@ -372,6 +379,8 @@ <h4 id="_custom_methods_on_django_orm_classes_to_translate_tofrom_our_domain_mod
372379
<td class="content">
373380
As in <a href="/book/chapter_02_repository.html">[chapter_02_repository]</a>, we use dependency inversion.
374381
The ORM (Django) depends on the model and not the other way around.
382+
383+
375384
</td>
376385
</tr>
377386
</table>
@@ -381,7 +390,9 @@ <h4 id="_custom_methods_on_django_orm_classes_to_translate_tofrom_our_domain_mod
381390
<div class="sect2">
382391
<h3 id="_unit_of_work_pattern_with_django">Unit of Work Pattern with Django</h3>
383392
<div class="paragraph">
384-
<p>The tests don&#8217;t change too much:</p>
393+
<p>
394+
395+
The tests don&#8217;t change too much:</p>
385396
</div>
386397
<div id="test_uow_django" class="exampleblock">
387398
<div class="title">Adapted UoW tests (tests/integration/test_uow.py)</div>
@@ -483,15 +494,21 @@ <h3 id="_unit_of_work_pattern_with_django">Unit of Work Pattern with Django</h3>
483494
instrumenting the domain model instances themselves, the
484495
<code>commit()</code> command needs to explicitly go through all the
485496
objects that have been touched by every repository and manually
486-
update them back to the ORM.</p>
497+
update them back to the ORM.
498+
499+
</p>
487500
</li>
488501
</ol>
489502
</div>
490503
</div>
491504
<div class="sect2">
492505
<h3 id="_api_django_views_are_adapters">API: Django Views Are Adapters</h3>
493506
<div class="paragraph">
494-
<p>The Django <em>views.py</em> file ends up being almost identical to the
507+
<p>
508+
509+
510+
511+
The Django <em>views.py</em> file ends up being almost identical to the
495512
old <em>flask_app.py</em>, because our architecture means it&#8217;s a very
496513
thin wrapper around our service layer (which didn&#8217;t change at all, by the way):</p>
497514
</div>
@@ -537,7 +554,8 @@ <h3 id="_api_django_views_are_adapters">API: Django Views Are Adapters</h3>
537554
<div class="sect2">
538555
<h3 id="_why_was_this_all_so_hard">Why Was This All So Hard?</h3>
539556
<div class="paragraph">
540-
<p>OK, it works, but it does feel like more effort than Flask/SQLAlchemy. Why is
557+
<p>
558+
OK, it works, but it does feel like more effort than Flask/SQLAlchemy. Why is
541559
that?</p>
542560
</div>
543561
<div class="paragraph">
@@ -549,7 +567,8 @@ <h3 id="_why_was_this_all_so_hard">Why Was This All So Hard?</h3>
549567
high).</p>
550568
</div>
551569
<div class="paragraph">
552-
<p>Because Django is so tightly coupled to the database, you have to use helpers
570+
<p>
571+
Because Django is so tightly coupled to the database, you have to use helpers
553572
like <code>pytest-django</code> and think carefully about test databases, right from
554573
the very first line of code, in a way that we didn&#8217;t have to when we started
555574
out with our pure domain model.</p>
@@ -570,7 +589,8 @@ <h3 id="_why_was_this_all_so_hard">Why Was This All So Hard?</h3>
570589
<div class="sect2">
571590
<h3 id="_what_to_do_if_you_already_have_django">What to Do If You Already Have Django</h3>
572591
<div class="paragraph">
573-
<p>So what should you do if you want to apply some of the patterns in this book
592+
<p>
593+
So what should you do if you want to apply some of the patterns in this book
574594
to a Django app? We&#8217;d say the following:</p>
575595
</div>
576596
<div class="ulist">
@@ -610,7 +630,8 @@ <h3 id="_what_to_do_if_you_already_have_django">What to Do If You Already Have D
610630
<div class="sect2">
611631
<h3 id="_steps_along_the_way">Steps Along the Way</h3>
612632
<div class="paragraph">
613-
<p>Suppose you&#8217;re working on a Django project that you&#8217;re not sure is going
633+
<p>
634+
Suppose you&#8217;re working on a Django project that you&#8217;re not sure is going
614635
to get complex enough to warrant the patterns we recommend, but you still
615636
want to put a few steps in place to make your life easier, both in the medium
616637
term and if you want to migrate to some of our patterns later. Consider the following:</p>
@@ -657,7 +678,8 @@ <h3 id="_steps_along_the_way">Steps Along the Way</h3>
657678
</table>
658679
</div>
659680
<div class="paragraph">
660-
<p>For more thoughts and actual lived experience dealing with existing
681+
<p>
682+
For more thoughts and actual lived experience dealing with existing
661683
applications, refer to the <a href="/book/epilogue_1_how_to_get_there_from_here.html">epilogue</a>.</p>
662684
</div>
663685
</div>
@@ -680,7 +702,7 @@ <h3 id="_steps_along_the_way">Steps Along the Way</h3>
680702
</div>
681703
<div id="footer">
682704
<div id="footer-text">
683-
Last updated 2020-03-17 09:07:44 UTC
705+
Last updated 2020-03-20 13:47:19 UTC
684706
</div>
685707
</div>
686708
<style>

book/appendix_ds1_table.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@
131131
<h2 id="appendix_ds1_table">Appendix A: Summary Diagram and Table</h2>
132132
<div class="sectionbody">
133133
<div class="paragraph">
134-
<p>Here&#8217;s what our architecture looks like by the end of the book:</p>
134+
<p>
135+
Here&#8217;s what our architecture looks like by the end of the book:</p>
135136
</div>
136137
<div id="recap_diagram" class="imageblock">
137138
<div class="content">
@@ -236,6 +237,9 @@ <h2 id="appendix_ds1_table">Appendix A: Summary Diagram and Table</h2>
236237
</tr>
237238
</tbody>
238239
</table>
240+
<div class="paragraph">
241+
<p></p>
242+
</div>
239243
</div>
240244
</div>
241245
<div class="prev_and_next_chapter_links">
@@ -246,7 +250,7 @@ <h2 id="appendix_ds1_table">Appendix A: Summary Diagram and Table</h2>
246250
</div>
247251
<div id="footer">
248252
<div id="footer-text">
249-
Last updated 2020-03-17 09:07:44 UTC
253+
Last updated 2020-03-20 13:47:19 UTC
250254
</div>
251255
</div>
252256
<div><div id="disqus_thread" style="margin: 10px"></div>

book/appendix_project_structure.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@
131131
<h2 id="appendix_project_structure">Appendix B: A Template Project Structure</h2>
132132
<div class="sectionbody">
133133
<div class="paragraph">
134-
<p>Around <a href="/book/chapter_04_service_layer.html">[chapter_04_service_layer]</a>, we moved from just having
134+
<p>
135+
Around <a href="/book/chapter_04_service_layer.html">[chapter_04_service_layer]</a>, we moved from just having
135136
everything in one folder to a more structured tree, and we thought it might
136137
be of interest to outline the moving parts.</p>
137138
</div>
@@ -574,7 +575,8 @@ <h3 id="_dockerfile">Dockerfile</h3>
574575
<div class="sect2">
575576
<h3 id="_tests">Tests</h3>
576577
<div class="paragraph">
577-
<p>Our tests are kept alongside everything else, as shown here:</p>
578+
<p>
579+
Our tests are kept alongside everything else, as shown here:</p>
578580
</div>
579581
<div id="tests_folder" class="exampleblock">
580582
<div class="title">Tests folder tree</div>
@@ -630,7 +632,8 @@ <h3 id="_wrap_up">Wrap-Up</h3>
630632
</ul>
631633
</div>
632634
<div class="paragraph">
633-
<p>We doubt that anyone will end up with <em>exactly</em> the same solutions we did, but we hope you
635+
<p>
636+
We doubt that anyone will end up with <em>exactly</em> the same solutions we did, but we hope you
634637
find some inspiration here.</p>
635638
</div>
636639
</div>
@@ -668,7 +671,7 @@ <h3 id="_wrap_up">Wrap-Up</h3>
668671
</div>
669672
<div id="footer">
670673
<div id="footer-text">
671-
Last updated 2020-03-17 09:07:44 UTC
674+
Last updated 2020-03-20 13:47:19 UTC
672675
</div>
673676
</div>
674677
<style>

book/appendix_validation.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@
131131
<h2 id="appendix_validation">Appendix E: Validation</h2>
132132
<div class="sectionbody">
133133
<div class="paragraph">
134-
<p>Whenever we&#8217;re teaching and talking about these techniques, one question that
134+
<p>
135+
Whenever we&#8217;re teaching and talking about these techniques, one question that
135136
comes up over and over is "Where should I do validation? Does that belong with
136137
my business logic in the domain model, or is that an infrastructural concern?"</p>
137138
</div>
@@ -734,7 +735,8 @@ <h3 id="_validating_pragmatics">Validating Pragmatics</h3>
734735
domain model. When we receive a message like "allocate three million units of
735736
<code>SCARCE-CLOCK</code> to order 76543," the message is <em>syntactically</em> valid and
736737
<em>semantically</em> valid, but we&#8217;re unable to comply because we don&#8217;t have the stock
737-
available.</p>
738+
available.
739+
</p>
738740
</div>
739741
</div>
740742
</div>
@@ -746,7 +748,7 @@ <h3 id="_validating_pragmatics">Validating Pragmatics</h3>
746748
</div>
747749
<div id="footer">
748750
<div id="footer-text">
749-
Last updated 2020-03-17 09:07:44 UTC
751+
Last updated 2020-03-20 13:47:19 UTC
750752
</div>
751753
</div>
752754
<style>

0 commit comments

Comments
 (0)