Fl4m3Ph03n1x

Fl4m3Ph03n1x

In page 166 the authors present the following code (specs added by me):

  @spec start_quiz(Quiz.t, DateTime.t) :: reference
  def start_quiz(quiz, now) do
    Logger.info("starting quiz #{quiz.fields.title}...")
    QuizManager.build_quiz(quiz.fields)
    Enum.each(quiz.templates, &add_template(quiz, &1))

    timeout = DateTime.diff(quiz.end_at, now, :millisecond)
    Process.send_after(self(), {:end_quiz, quiz.fields.title}, timeout)
  end

This code is supposed to go on the file Mastery.Boundary.Proctor. However such code won’t compile, even after I finished the section, the reason being add_template is not defined:


== Compilation error in file lib/mastery/boundary/proctor.ex ==
** (CompileError) lib/mastery/boundary/proctor.ex:32: undefined function add_template/2
    (elixir) src/elixir_locals.erl:108: :elixir_locals."-ensure_no_undefined_local/3-lc$^0/1-0-"/2
    (elixir) src/elixir_locals.erl:109: anonymous fn/3 in :elixir_locals.ensure_no_undefined_local/3
    (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6

Shouldn’t it not be Enum.each(quiz.templates, Quiz.add_template(quiz, &1)) instead?
I have re-read the proctor section several times now and I can’t find the page where this function is. I have to be missing something!

Also, the book mentions this is the file Workers/lib/mastery/bonudary/proctor.ex. Shouldn’t it not be Mastery/lib.... instead?

Would appreciate any possible guidance, I am kinda lost in this section :S

1
Post #43
JEG2

JEG2

Author of Designing Elixir Systems with OTP

There is a tiny wrapper in our source code for the Proctor module, though we don’t end up showing it in the book. Here’s the function:

  def add_template(quiz, template_fields) do
    QuizManager.add_template(quiz.fields.title, template_fields)
  end

It looks like this may be a simple oversight on our part. Sorry about the confusion!

This is just the devision of our code by book chapters that you’ll see if you download our source.

1
Post #44
Fl4m3Ph03n1x

Fl4m3Ph03n1x

On page 181, you have the following text:

  • Configure the project to use a repository.
  • Add a perstence function to our external API.
  • Wire that persistence function into the Boundary.QuizSession GenServer.

In the second bullet point, I believe you mean “persistence” instead of “perstence

:smiley:

1
Post #45
JEG2

JEG2

Author of Designing Elixir Systems with OTP

Good catch. Thanks!

1
Post #46
matreyes

matreyes

I’m just waiting for a coupon to buy (ElixirForum is not longer available).

1
Post #47
AstonJ

AstonJ

A new coupon will be coming later this month :003:

4
Post #48
Fl4m3Ph03n1x

Fl4m3Ph03n1x

I prefer supporting the authors early on and be an overall pain in the backs by constantly reporting typos and other things I notice :stuck_out_tongue:

I do believe however this somehow helps them :smiley: (don’t crush my dreams by telling me otherwise!)

0
Post #49
Fl4m3Ph03n1x

Fl4m3Ph03n1x

There are a few things in chapter 9 I would like to comment regarding configuration.

  1. Now when we create projects in Elixir the config folder is missing. This change was introduced in Elixir 1.9 (Elixir v1.9 released - The Elixir programming language) and it may generate confusion for readers of the book, as those who create the mastery project using Elixir 1.9 will have a different project structure than those who don’t. (use Mix.Config is soft deprecated, config folder no longer created)

  2. In page 181 in Configure Mastery for Persistence the first config file is missing use Mix.Config at the top, which causes the file not to work. It is also missing the usual boilerplate line where you import config depending on the value of MIX_ENV.

Point 2 was specially painful for me as a reader and I had to download and checkout the source code to fix the issues I was having.

Entering the Phoenix part!

1
Post #50
JEG2

JEG2

Author of Designing Elixir Systems with OTP

Thanks for pointing these details out. In this case, it’s a matter of Elixir’s default behavior changing after we wrote the code. It use to generate the mentioned files and include the mentioned lines.

In these instances, it’s probably worth a look a look at our source code to see what’s really in the files. And, of course, we’ll fix these kind of things if we ever do a second edition.

1
Post #51
Fl4m3Ph03n1x

Fl4m3Ph03n1x

I have finally finished the book. With 30 to 60 minutes per day, 2-3 times a week, it took me =~ 6 months to finish it, with all the code samples, the DB, dialyzer and really making an effort to understand as much as I can.

It took me so long to finish this, that the slogan for the book “Do Fun Things with Big Loud Wildebeests” actually changed to Worker bees while I was reading it!

Overall I liked the layered architecture in the book. I know Bruce is a fan of layers and even though I am not sure I agree with some of the decisions taken the book explains itself in a way that helps me understand why certain decisions were made - for the authors, development is a series of trade-offs, a fact they make very clear.

The part I enjoyed the most though (I believe this is mainly from James) was the decoupling of the DB. They create a new project inside the main project of the book. At first it looks like non-sene: why not use another GitHub Repo or an Umbrella app? But after that, they actually explain all the differences and all the benefits of each approach an I can only say I became better by reading and understanding them all. Genius solution!

It also solves a problem I’ve had for years in Elixir now - to find a standardized way of solving persistence in Elixir (something I have really missed in other books).

The also pays some attention to tests, although they don’t follow TDD. I’d say it is still worth a look, specially for the integration tests on chapter 9 with timers.

Overall I would recommend this for anyone doing backend. If you feel you are comfortable with Elixir and GenServers, and your main struggles are architecture and decoupling, I would definitely recommend this !

8
Post #52