Clarify suggested exercises around the blog post example

Fixes #1079.
This commit is contained in:
Carol (Nichols || Goulding)
2018-03-02 15:50:54 -05:00
parent 1291620a39
commit 3fc2afec6d
3 changed files with 12 additions and 6 deletions
+6 -3
View File
@@ -1029,10 +1029,12 @@ The implementation using the state pattern is easy to extend to add more
functionality. To see the simplicity of maintaining code that uses the state
pattern, try a few of these suggestions:
* Allow users to add text content only when a post is in the `Draft` state.
* Add a `reject` method that changes the posts state from `PendingReview` back
to `Draft`.
to `Draft`.
* Require two calls to `approve` before the state can be changed to `Published`.
* Allow users to add text content only when a post is in the `Draft` state.
Hint: have the state object responsible for what might change about the
content, but not responsible for modifying the `Post`.
One downside of the state pattern is that, because the states implement the
transitions between states, some of the states are coupled to each other. If we
@@ -1235,7 +1237,8 @@ production.
Try the tasks suggested for additional requirements that we mentioned at the
start of this section on the `blog` crate as it is after Listing 17-20 to see
what you think about the design of this version of the code.
what you think about the design of this version of the code. Note that some of
the tasks might be completed already in this design!
Weve seen that even though Rust is capable of implementing object-oriented
design patterns, other patterns, such as encoding state into the type system,
Binary file not shown.
@@ -480,10 +480,12 @@ The implementation using the state pattern is easy to extend to add more
functionality. To see the simplicity of maintaining code that uses the state
pattern, try a few of these suggestions:
* Allow users to add text content only when a post is in the `Draft` state.
* Add a `reject` method that changes the posts state from `PendingReview` back
to `Draft`.
to `Draft`.
* Require two calls to `approve` before the state can be changed to `Published`.
* Allow users to add text content only when a post is in the `Draft` state.
Hint: have the state object responsible for what might change about the
content, but not responsible for modifying the `Post`.
One downside of the state pattern is that, because the states implement the
transitions between states, some of the states are coupled to each other. If we
@@ -694,7 +696,8 @@ production.
Try the tasks suggested for additional requirements that we mentioned at the
start of this section on the `blog` crate as it is after Listing 17-20 to see
what you think about the design of this version of the code.
what you think about the design of this version of the code. Note that some of
the tasks might be completed already in this design!
Weve seen that even though Rust is capable of implementing object-oriented
design patterns, other patterns, such as encoding state into the type system,