Your topic ideas for bloggers

I propose a guide for (experienced) OOP-devs.

Stuff I think should be covered:

  1. use composition instead of inheritance

Don’t do what I did, implement inheritance with GenServers

defmodule Base do
  use GenServer

  def handle_cast(:foo, state), do: ...
  def handle_cast(:bar, state), do: ...
end

defmodule Derived do
  use GenServer

  def handle_cast(:foo, state), do: ...
  def handle_cast(:baz, state), do: ...

  # !!!
  def handle_cast(method, state), do: Base.handle_cast(method, state)
end
  1. Understand why immutability is great but comes at a cost - You give up mutability - I often miss this part in FP-introductions, which directly leads to …

  2. survival without mutability (understand, ideally implement yourself) map-reduce algorithms. Learn to structure data so that its easy to handle without mutability.

  3. learn to love pure functions (testability! understandable code!) which leads to

  4. functional patterns - starting with a simple pipe, then with, understand plug and maybe functional core, imperative shell (with proposing this pattern Sasa Juric vastly improved some code of mine here so I love it)

2 Likes