Casing Conventions

These are the most common casing rules:

PascalCase

snake_case

camelCase

kebab-case

 

PascalCase is used in C# for classes and methods.

Java uses PascalCase for classes but camelCase for methods.

Elixir uses PascalCase for modules and snake_case for variables and functions.

CSS uses kebab-case.

Getting Started With Phoenix 1.4

These are the notes from working through the new version of the book.

Firstly Phoenix 1.4 has been released so the Phoenix install instructions are out of date so here is the update:

$ mix archive.uninstall phx_new
$ mix archive.install hex phx_new 1.4.0

(from: https://phoenixframework.org/blog/phoenix-1-4-0-released)

I also did not have postgres installed:

$ brew install postgres

initdb /usr/local/var/postgres

/usr/local/opt/postgres/bin/createuser -s postgres

(from https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist)

This will get you to the end of the hello app.

Railway Oriented Programming


https://medium.com/elixirlabs/railway-oriented-programming-in-elixir-with-pattern-matching-on-function-level-and-pipelining-e53972cede98

The common recommendation in Elixir is to let it crash (more accurately it is let a supervisor handle the error ). This is normally the case when you have small processes.

There is another pattern that can be used.

If all of your functions return {:ok, something} or {:error, reason} then technically the function is a Monad. This allows pipelines in which data and errors can be passed through cleanly.

Railway oriented programming takes this a stage further by having defined pipelines that have a good and an error route. It is possible for errors to be handled and returned to the good track.

https://zohaib.me/railway-programming-pattern-in-elixir/ 

Things worth studying in Elixir

It’s worth looking over the basics libraries of a language from time to time to see if you have missed anything useful.

For example Elixir has the very useful:

https://hexdocs.pm/elixir/Enum.html#map_join/3

This allows you to map some data then join it together as a single operation.

https://hexdocs.pm/elixir/Enum.html#min_max/2

This finds the smallest and largest items in an Enumerable by a given definition.

https://hexdocs.pm/elixir/String.html#split/3

This splits a string on a pattern and allows you to drop the empty elements. This is especially useful if there are patterns that you want to filter out as well. One iteration will split and remove the irrelevant items.