Programming Elixir Chapter 14 Notes


Tooling

Working through all the tooling examples.

Debugging

  1. Use the new dbg instead of the IEx.pry as shown to trigger a debug.

  2. You can only break! on public functions.

  3. You also can only next on public functions.

  4. Dave’s note is that he tends to raise an Exception to see what’s going on when he’s debugging.

Testing

  1. I’ve been annoyed that VSCode’s does code hinting in comments. Now I see why, DocTest.

  2. Adding DocTest to the TableFormatter caused me to change print_header and print_separator to table_header and table_separator and print after call. Further promotes the ‘do one thing’ idiom and simplifies testing.

  3. I can see doing regular DocTests.

  4. DocTests are good for demonstrating usage and do not replace UnitTests.

  5. Added some fixtures to TableFormatter tests. Had been using @values.

  6. fixture is just a name, could be anything, but fixture is descriptive.

  7. setup can declare a tuple or a function returning a tuple.

  8. Add an on_exit section to the setup block to do any cleanup.

  9. Will need to read ExUnitProperties and dig into examples.

  10. Added ExCoveralls to issues project.

Code Dependencies

mix xref unreachable
mix xref warnings
mix xref callers [Module or function]

mix xref graph --format dot
dot -Grankdir=LR -Epenwidth=2 -Tpng -Ecolor=#a0a0a0 -o xref_graph.png xref_graph.dot

Server Monitoring

iex> :observer.start()

Source Code Formatting

I’m letting the IDE do the work.

mix format

All notes and comments are my own opinion. Follow me at @rgacote@genserver.social