Skip to content
0:00 / 0:00

#erlang#cleancode#patternmatching

Writing Quality Code in Erlang

Next Day Video

68K subscribers • 16 videos on Hallway

YouTube
  • Recommended by 3 people: 2 in engineering communities and 1 curated list.
  • Presented by Garrett Smith
  • An opinion. It argues one side of a question engineers disagree on.

Intermediate. Assumes working knowledge.

19K views12 years ago3 recommendations

Programming languagesSoftware designElixir and ErlangSimplicity and complexityRefactoring and legacy code

Garrett Smith demonstrates how to write highly readable, maintainable, and beautiful Erlang code by focusing on intent and structure.

Garrett Smith chicagoerlang.com/garrett-smith.html We all know that one of Erlang's greatest weaknesses is its syntax. It doesn't resemble Ruby at all! In this talk Garrett will show how Erlang can be used to write high quality, beautiful code. That is, code that's readable, maintainable and that obviously reflects the intent of its author.

Why it's here

3 people recommend this

What people say. Recommended as a great talk on writing clean, refactorable Erlang and Elixir code.

programming-talkscurated list on GitHubRecommends

Under “Erlang”

Writing Quality Code in Erlang 00:40:47 by **Garrett Smith** (2014)

u/wschroedin r/elixir • Recommends

On “Accessing Structs in Elixir - (bloody beginner mistakes)”

…for File.stat where you could detect and firmly know why the file cannot be statted. You could do something like this: case File.stat(file_name) do {:ok, info} -> info.access {:error, reason} -> handle_reason(reason) end Of course, that introduces some ugly error-handling code, so following in the style of Garret Smith (link to this video you could name your branches: def get_info({:ok, info}), do: info def get_info({:error, reason}), do: ... # handle problems info = get_info File.stat(file_name) Or name get_info in a way that seems like a "type" or something. Addendum: Another approach is to use a monadic bind approach. I haven't played with that much…

u/yawaraminin r/elixir • Recommends

On “How easy is it to refactor Elixir code?”

This talk helped me a lot: link to this video It’s focused on Erlang but applies equally well to Elixir. For me personally, Elixir refactorability takes a hit because it doesn’t have more powerful static typing, but it makes up almost all the difference with pattern matching, fast feedback, and the fail-fast strategy that it encourages. You’ll need to change your approach a bit to catch refactoring errors—focus on a wider range for testing (think branch-level coverage)—but the payoff is worth it.