diff --git a/_posts/2021-06-14-new-book-code-that-fits-in-your-head.html b/_posts/2021-06-14-new-book-code-that-fits-in-your-head.html index dba9d75f..c07f3810 100644 --- a/_posts/2021-06-14-new-book-code-that-fits-in-your-head.html +++ b/_posts/2021-06-14-new-book-code-that-fits-in-your-head.html @@ -78,7 +78,7 @@
- I was recently playing around with the example code from my book Code That Fits in Your Head, refactoring the Table
class to use a predicative NaturalNumber wrapper to represent a table's seating capacity.
+ I was recently playing around with the example code from my book Code That Fits in Your Head, refactoring the Table
class to use a predicative NaturalNumber wrapper to represent a table's seating capacity.
Originally, the Table
constructor and corresponding read-only data looked like this:
@@ -120,7 +120,7 @@
- Second, even if the resolution is easy, as is the case here, if you don't understand the underlying cause and effect, you can easily build a cargo cult-like 'understanding' of programming. This could become one such experience: All wrapper types must implement IComparable
.
+ Second, even if the resolution is easy, as is the case here, if you don't understand the underlying cause and effect, you can easily build a cargo cult-like 'understanding' of programming. This could become one such experience: All wrapper types must implement IComparable
, or some nonsense like that.
Unless people are getting hurt or you are bleeding money because of the error, seek first to understand, and only then fix the problem. @@ -215,7 +215,7 @@
Schedule
, while the rest is 'just' assertions.
- Since I had noticed that OrderedEnumerable`1
on the stack I was on the lookout for an expression that would sort an IEnumerable<T>
. The ScheduleImp
method surprised me, though, because the reservations
parameter is an array. If there was any problem sorting it, it should have blown up much earlier.
+ Because I had noticed that OrderedEnumerable`1
on the stack, I was on the lookout for an expression that would sort an IEnumerable<T>
. The ScheduleImp
method surprised me, though, because the reservations
parameter is an array. If there was any problem sorting it, it should have blown up much earlier.
I really should be paying more attention, but despite my best resolution to proceed methodically, I was chasing the wrong clue. @@ -400,7 +400,7 @@
MaitreD
constructor had run and the object was 'safely' initialised, it actually wasn't.
- The implication is that there's a 'disconnect' between the constructor and the Allocate
method. The error actually happens during initialisation (i.e. in the constructor), but it only manifests when you run the method.
+ The implication is that there's a 'disconnect' between the constructor and the Allocate
method. The error actually happens during initialisation (i.e. in the caller of the constructor), but it only manifests when you run the method.
Ever since I discovered the IReadOnlyCollection<T> interface in 2013 I've resolved to favour it over IEnumerable<T>
. This is one example of why that's a good idea.