I’m coming from Ruby and Rails. I have read some Elixir and Phoenix books. They shed a lot of light about building applications in Elixir. What I’m not clear on is what patterns are promoted for growing Elixir applications. Little things are promoted, as far as I can tell, but it doesn’t get too specific. I’m a heavy book consumer and in Ruby the books that I view as extremely well thought out and thorough include:
Rails antipatterns
99 Bottles of OOP
Confident Ruby
Practical Object Oriented Design using Ruby (POODR)
Refactoring - Ruby Edition
Ruby Science
(and the list goes on)
Are there any books in the Elixir world that cover these topics (design, refactoring) as deeply as these books do in Ruby?
Further to what Koko has said, if you like Dave’s talk you might also be interested in his course: Elixir for Programmers (PragDave) (Currently on offer for $30!) (have a look at the comments/reviews in the thread). It’s not really about refactoring and such, but you do get a look into how Dave goes about architecting software (at least at the time he recorded the course)
The last advise, for Rails developpers, Ecto is not AR, but You can do equal job… (same same, but different) Here is a post about a free resource on Ecto.
FP is just a mean to achieve greater goal, Here is a post from Erlang creator, about Erlang.
Once You reach the syntax barrier, You will see it allows You to have a complete isolation…
In complete isolation, You can have millions of processes working together. Coupled with a faillback mecanism (Supervisor) You can build softwares that are fault tolerant.
Apart from Functional patterns, there are Design Patterns for processes, it’s called OTP.
Regarding patterns/refactoring, in OOP there’s the idea of focused objects/little things. This is represented in objects like Services, Policies, Queries, Presenters, Decorators, etc… Are these patterns relevant in the elixir world as well? Doing some Googling doesn’t reveal much.
The beginner examples in both ruby and elixir show much of the examples either in irb/iex or in a Rails/Phoenix controller. This does not scale. In the Rails world I just look up some common patterns and I get a plethora of results. This does not happen with Elixir so I think I don’t know the patterns (and possibly they aren’t even called patterns).
I took the same way You did, just a bit earlier. As You, I read all the Ruby books You mentionned…
I can remember the depressing feeling of not finding the equivalent of what I learned, all those things Sandi Metz was praising… is it just replaced by MFA?
In Ruby, often You find small objects, used for one function only, that could be parser.parse(), presenter.present()… anything like this. In FP You pass a function.
High order functions are so powerful (something Ruby touch with Lambda) that You don’t need Template, or Strategy patterns.
In Erlang/Elixir, we have some famous Erlangelist… this is one of my favourite talk to understand why this difference is so appealing.
Have you read Elixir in Action? Much of the book builds on the same example application of a todo system, with increasing complexity (adding a caching layer, persistency, fault-tolerancy, a web interface, and distribution). When I started out with Elixir I found the way this example evolved over the course of the book a really good guideline for how to evolve a real-world Elixir application.
Now that I’ve read (most of) it, it’s worth noting that the Ecto book also has a chapter on application design (covers pure/impure, Contexts, Umbrellas) while of course Programming Phoenix also covers application design in terms of Contexts - I highly recommend both books
Let’s not forget that BEAM languages also enable CP - Concurrent Programming. The core pattern is a behaviour (see also discussion).
Garret Smith had an effort some years ago to capture some Erlang Patterns which are still available in some markdown documents here - the mostly apply to Elixir as well.
Just trying to complement what others have already mentioned. I found this book about functional programming very useful for someone with an OO background:
However, I think you better off learning the basics of FP and move where your interests take you. You’ll be amazed at how much you can accomplish with just modules and functions.