You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: chapter_01_domain_model.asciidoc
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,7 @@ too late, and OO enthusiasts will tell you to look further back to Ivar
75
75
Jacobson and Grady Booch; the term has been around since the mid-1980s.]
76
76
and it's been a hugely successful movement in transforming the way people
77
77
design software by focusing on the core business domain. Many of the
78
-
architecture patterns that we cover in this book—including Entity, Aggregate, Value Object (see <<chapter_06_uow>>), and Repository (in
78
+
architecture patterns that we cover in this book—including Entity, Aggregate, Value Object (see <<chapter_07_aggregate>>), and Repository (in
79
79
<<chapter_02_repository,the next chapter>>)—come from the DDD tradition.
80
80
81
81
In a nutshell, DDD says that the most important thing about software is that it
@@ -212,6 +212,11 @@ We can't allocate the same line twice. For example:
212
212
Batches have an _ETA_ if they are currently shipping, or they may be in _warehouse stock_. We allocate to warehouse stock in preference to shipment batches. We allocate to shipment batches in order of which has the earliest ETA.
213
213
****
214
214
215
+
=== Unit Testing Domain Models
216
+
217
+
We're not going to show you how TDD works in this book, but we want to show you
218
+
how we would construct a model from this business conversation.((("unit testing", "of domain models", id="ix_UTDM")))((("domain modeling", "unit testing domain models", id="ix_dommodUT")))
We're not going to show you how TDD works in this book, but we want to show you
234
-
how we would construct a model from this business conversation.((("unit testing", "of domain models", id="ix_UTDM")))((("domain modeling", "unit testing domain models", id="ix_dommodUT")))
235
-
236
235
Here's what one of our first tests might look like:
237
236
238
237
[[first_test]]
@@ -970,7 +969,7 @@ Not everything has to be an object::
970
969
or `get_baz()` waiting to happen.((("functions")))
971
970
972
971
This is the time to apply your best OO design principles::
973
-
Revisit the ((("object-oriented design principles")))SOLID principles and all the other good heuristics like "a versus is-a,"
972
+
Revisit the ((("object-oriented design principles")))SOLID principles and all the other good heuristics like "has a versus is-a,"
974
973
"prefer composition over inheritance," and so on.
975
974
976
975
You'll((("domain modeling", startref="ix_dommod"))) also want to think about consistency boundaries and aggregates::
Copy file name to clipboardExpand all lines: chapter_02_repository.asciidoc
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ We'll need a way to retrieve batch info from the database and instantiate our do
86
86
model objects from it, and we'll also need a way of saving them back to the
87
87
database.
88
88
89
-
_(What? Oh, "gubbins" is a British word for "stuff." You can just ignore that. It's pseudocode, OK?)_
89
+
_What? Oh, "gubbins" is a British word for "stuff." You can just ignore that. It's pseudocode, OK?_
90
90
91
91
92
92
=== Applying the DIP to Data Access
@@ -269,7 +269,7 @@ inversion and the Repository pattern to Django.
269
269
==== Inverting the Dependency: ORM Depends on Model
270
270
271
271
Well, thankfully, that's not the only way to use SQLAlchemy.((("object-relational mappers (ORMs)", "ORM depends on the data model")))((("domain model", "translating to relational database", "ORM depends on the model")))((("dependency inversion principle", "ORM depends on the data model")))((("SQLAlchemy", "explicit ORM mapping with SQLAlchemy Table objects")))((("classical mapping")))((("mappers"))) The alternative is
272
-
to define your schema separately, and an explicit _mapper_ for how to convert
272
+
to define your schema separately, and to define an explicit _mapper_ for how to convert
273
273
between the schema and our domain model, what SQLAlchemy calls a
You should also check out this PyCon talk, https://oreil.ly/s3e05["Mocking and Patching Pitfalls"],
670
670
by our esteemed tech reviewer, Ed Jung, which also addresses mocking and its
671
-
alternatives.(((""Test-Driven Development: That's Not What We Meant"", primary-sortas="Test-Driven Development")))((("Freeman, Steve")))((("PyCon talk on Mocking Pitfalls")))((("Jung, Ed")))
672
-
673
-
And while we're recommending talks, don't miss Brandon Rhodes talking about
671
+
alternatives.(((""Test-Driven Development: That's Not What We Meant"", primary-sortas="Test-Driven Development")))((("Freeman, Steve")))((("PyCon talk on Mocking Pitfalls")))((("Jung, Ed"))) And while we're recommending talks, don't miss Brandon Rhodes talking about
674
672
https://oreil.ly/oiXJM["Hoisting Your I/O"],
675
673
which really nicely covers the issues we're talking about, using another simple example.((("hoisting I/O")))((("Rhodes, Brandon")))
0 commit comments