A talk explaining how to define `good code`. Using `Code Complete` as a reference to guide over the quality definition and introducing Linters (Credo) and Dialyzer (Dialyxir)
3. ● Very useful item to up your RPG
character level
● I’d recommend to buy at least 5
● Drops from some medium level
mobs
Panacea
4. ● Was a goddess of universal remedy
● Panacea traditionally had a potion
with which she healed the sick
● A substance meant to cure all
diseases
● "Something used to solve all
problems"
Panacea (from Greek mythology)
5. “
Any fool can write code that a
computer can understand.
Good programmers write code that
humans can understand.
– Martin Fowler
9. You write readable code because it helps other
people to read your code“
Code Complete, Steve McConnel
Error rate
Comprehensibility
Reviewability
Debugging
Modifiability
20. ● Erlang Open Telecom Protocol
● it's not that much about telecom anymore
● libraries available with the virtual machine
● OTP compliant: basically following process architecture
OTP (Open Telecom Protocol)
21. BEAM
● Bogdan's Erlang Abstract Machine
○ emulator and loader were first implemented by Bogumil Hausman
● Björn's Erlang Abstract Machine
○ completely rewritten by Björn Gustavsson
● BEAM bytecode files have the .beam file extension
22. ● Static analysis tool that identifies software
discrepancies, such as:
○ definite type errors
○ code that has become dead
○ unreachable because of programming error
○ unnecessary tests
● Erlang modules or entire (sets of) applications
(.beam files)
DIscrepancy AnaLYZer for ERlang programs
DIALYZER
23. The Persistent Lookup Table (PLT)
● Stores the result of an analysis (acting like a cache)
● Then it can be used as starting point for later analyses
● .plt file extension
24. Gradual Typing
Best of Static and Dynamic Worlds:
● Some variables and functions can have type declaration
● Developer decides which ones makes sense to declare
● Tool or Compiler can still check correctness and consistency of
usage
25. ● It allows us to generate tests from the code
examples in a module/function/macro's
documentation
● Similar to Python's doctest
● Able to refer to specific numbered scenarios
● Copy-pasting examples from an actual IEx session
Doctests
26. ● Run Dialyzer (test environment) to see how the
types in API and the usage in the tests (calls)
Using Dialyzer for tests
33. is a tool that analyzes source code to flag
programming errors, bugs, stylistic errors,
and suspicious constructs
- Wikipedia
What is a linter?
“
34. Homoiconicity
● The code used to express a program is
written using the data structures of
that language
● The Lisp family languages (Common
Lisp, Scheme, Clojure, etc)
● Code is Data, Data is Code
35. Abstract Syntax Tree (AST)
● It tells us how expressions are represented
● Internal representation of our code
● Using quote/2 we can convert Elixir code into its
representation
47. References
● Code Complete: A Practical Handbook of Software Construction
● Elixir, processes and this thing called OTP
● Introducing HDD: Hughes Driven Development, com José Valim
● Credo
● Dialyzer
● Dialixyr
● Ebert: the code review assistant for your organization
● Metaprogramming in Elixir
48. More References
● ElixirConf 2016 - Dialyzer: Optimistic Type Checking for Erlang and Elixir
by Jason Voegele
● Gradualizer: A Gradual Type System for Erlang
● Learn You Some Erlang: OTP