Skip to content

Commit 2134be8

Browse files
authored
Merge pull request #966 from DockYard-Academy/early_content_review
Task Drill Solutions
2 parents 3281ac8 + ed1208a commit 2134be8

10 files changed

+203
-78
lines changed

CONTRIBUTING.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ Have you tried turning it off and on again?
276276
<summary>Example Solution</summary>
277277

278278
```elixir
279-
initial_count = 0
280-
initial_count + high
279+
281280
```
282281

283282
</details>

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,4 @@ See [start.livemd](https://github.com/DockYard-Academy/curriculum/blob/main/star
105105

106106
<!-- course-outline-end -->
107107

108+

exercises/capstone_entity_relationship_diagram.livemd

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ See https://mermaid.js.org/syntax/entityRelationshipDiagram.html for the syntax.
7878
### Requirements
7979

8080
* Document the entities and their fields.
81-
* Document the associations (many-to-one, many-to-many, one-to-one) in your capstone project
81+
* Document the associations (many-to-one, many-to-many, one-to-one).
8282

8383
## Commit Your Progress
8484

exercises/games_supervised_score_tracker.livemd

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Increase the `ScoreTracker`'s score whenever a user wins the game.
6060
<!-- livebook:{"force_markdown":true} -->
6161

6262
```elixir
63-
# Games.ScoreTracker Should Be A Named Process, So It Is Not Necessary To Send The Pid.
63+
# Games.ScoreTracker should be a named process, so we don't need to provide the pid.
6464
{:ok, _pid} = Games.ScoreTracker.start_link()
6565
:ok = Games.Score.add_points(10)
6666
:ok = Games.Score.add_points(10)

exercises/group_project_blog.livemd

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ $ git init
124124

125125
Edit the `README.md` file initialized in your Phoenix project.
126126

127-
Include alteast the following information:
127+
Include at least the following information:
128128

129129
* Project Name
130130
* Project Summary

exercises/stack.livemd

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ In addition to the above, add documentation and at least one doctest for the `pu
5858

5959
This will be a **pair testing** exercise Using TDD (Test Driven Development). We recommend using Visual Studio Code LiveShare to collaborate.
6060

61-
1. One student (**the tester**) will write a test
61+
1. One student (**the tester**) will write a single test
6262
2. The other student (**the implementer**) will implement **only** the code necessary to make the test pass.
6363
3. **Swap roles after each test.**
6464

exercises/supervised_stack.livemd

+15-29
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ Mix.install([
3232

3333
## Supervised Stack
3434

35-
Previously we created a [Stack](./stack_server.livemd) [GenServer](https://hexdocs.pm/elixir/GenServer.html) process.
35+
You're going to create a stack project that starts a name [Stack](./stack_server.livemd) GenServer process under a supervisor.
3636

37-
We've made a slight modification to the `Stack` process by adding a `start_link/1` function so this named `Stack` can be started under a [Supervisor](https://hexdocs.pm/elixir/Supervisor.html).
37+
```
38+
mix new stack
39+
```
40+
41+
Here's an example Stack GenServer you can use.
3842

3943
```elixir
4044
defmodule Stack do
@@ -63,30 +67,13 @@ defmodule Stack do
6367
end
6468
```
6569

66-
We're able to push and pop elements off of the stack.
67-
68-
```elixir
69-
{:ok, stack_pid} = GenServer.start_link(Stack, [])
70-
71-
GenServer.call(stack_pid, {:push, 1}) |> IO.inspect(label: "push")
72-
GenServer.call(stack_pid, {:push, 2}) |> IO.inspect(label: "push")
73-
GenServer.call(stack_pid, {:push, 3}) |> IO.inspect(label: "push")
74-
75-
GenServer.call(stack_pid, :pop) |> IO.inspect(label: "pop")
76-
GenServer.call(stack_pid, :pop) |> IO.inspect(label: "pop")
77-
GenServer.call(stack_pid, :pop) |> IO.inspect(label: "pop")
78-
79-
# The Final State Is Empty.
80-
:sys.get_state(stack_pid)
81-
```
82-
83-
However, there's a bug. If we try to `pop/1` an item off of an empty stack, the process
70+
We're able to push and pop elements off of the stack. However, there's a bug. If we try to `pop/1` an item off of an empty stack, the process
8471
will crash due to a function clause error because the `handle_call/2` function expects a list with one or more elements.
8572

8673
Uncomment the following code to watch the `Stack` crash.
8774

8875
```elixir
89-
# {:ok, Pid} = GenServer.start_link(Stack, [])
76+
# {:ok, pid} = GenServer.start_link(Stack, [])
9077
# GenServer.call(stack_pid, :pop)
9178
```
9279

@@ -102,7 +89,7 @@ def handle_call(:pop, _from, []) do
10289
end
10390
```
10491

105-
Instead, you're going to start the Stack process under a supervisor so that it will be restarted when it crashes. In the Elixir cell below, start the `Stack` process under a supervisor so that it will restart with an empty stack when it crashes.
92+
Instead, you're going to start the `Stack` process under a supervisor in your application so that it will be restarted when it crashes.
10693

10794
<details style="background-color: lightgreen; padding: 1rem; margin: 1rem 0;">
10895
<summary>Example Solution</summary>
@@ -117,18 +104,17 @@ children = [
117104

118105
</details>
119106

120-
Keep in mind, if you have already started a supervisor with the `Stack` process, your livebook may crash. You can resolve this issue by simply re-running the cell below to start the supervisor again.
107+
<!-- livebook:{"break_markdown":true} -->
121108

122-
```elixir
109+
### Crash The Stack
123110

124-
```
125-
126-
You should be able to send a `:pop` message to the `Stack` process and the [Supervisor](https://hexdocs.pm/elixir/Supervisor.html) will restart the `Stack` process.
111+
Open the [IEx](https://hexdocs.pm/iex/IEx.html) shell and send the `Stack` a `:pop` message to cause it to crash and restart.
127112

128-
Uncomment and evaluate the code below to test your supervisor.
113+
<!-- livebook:{"force_markdown":true} -->
129114

130115
```elixir
131-
# GenServer.call(Stack, :pop)
116+
$ iex -S mix
117+
iex> GenServer.call(Stack, :pop)
132118
```
133119

134120
## Commit Your Progress

0 commit comments

Comments
 (0)