pillaiindu

pillaiindu

What do they actually mean when they say "Phoenix is not your application"?

I hear this sentence from almost every teacher, teaching Elixir and/or Phoenix. What does it actually mean?

Most Liked

peerreynders

peerreynders

The phrase was coined by Lance Halvorsen - Phoenix Is Not Your Application (ElixirConfEU 2016).

Topics:

Points

  • The idea isn’t actually new - but it seems that web development (RoR in particular) needed to rediscover the concept - e.g. Ruby Midwest 2011 - Keynote: Architecture the Lost Years by Robert Martin (and it wasn’t new back then either).
  • Design the application code in such a way that all its capabilities can be exposed via different user interfaces, e.g.:
  • command line interface
  • native desktop user interface (not something like React Native but more like Swift and not necessarily via a remote server but more like a local application).
  • web ui (Phoenix + browser frontend)

i.e. decouple the application logic entirely from the nature of the UI (the “mode of delivery” for the application’s capabilities).

  • Dave Thomas actually pushes the idea even further to “Your Database is not Your Application”
  • Don’t start by defining your DB tables - that is just your “data-at-rest”. Make informed design decisions based on your “data-in-motion” by designing your essential data transformations (based on your problem domain) first.
  • Pushed to the extreme this also means that your domain logic should be “persistence technology agnostic”.
  • Ultimately this goes back to the old idea of a “Layered Architecture”.
  • However this time around that “layered architecture” isn’t designed “bottom-up” (DB-first) nor “top-down” (UI-first) but “inside-out” (domain-capabilities-first). Conceptually the middle layer (domain-layer) defines all the “interfaces” that the lower layer (persistence-layer) and the upper layer (UI-layer) have to implement.
  • So the lower layer has to implement the interfaces so that the middle layer can retrieve the necessary data and save and update the necessary data. The upper layer has to implement interfaces to gain access to the middle layers capabilities.

FYI: Your database is not your application - by Hubert Łępicki - Code Europe Autumn 2016

14
Post #3
lance

lance

Author of Functional Web Development with Elixir, OTP, and Phoenix

My name is Lance Halvorsen and I endorse this message. :+1: :grinning:

If I could add one small bit to what @peerreynders has written here, it would be that OTP’s Application Behaviour is the thing that makes this way of working feel much more natural in Elixir/Erlang than in other ecosystems.

kokolegorille

kokolegorille

It means phoenix is not the main concern when You start your project. It should be business/domain logic first, and only then, wrap phoenix around.

@pragdave is advocating for this, and in his course, he starts building a game engine, then only after, he wraps it with a web interface. and shows how simple it is to change interface… like a text console interface.

In practice, that means umbrella project are strongly encouraged, as a way to separate concern.

Also, as a personal opinion, I find very nice to build simple domain modules, join them together, and only at the end, add phoenix as web interface :slight_smile:

I think it was a Rails concern at first, where building huge monolithic application was usual.

Where Next?

Popular in Questions Top

siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: <h1>Create Post</h1> <%= ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43806 214
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39523 209
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54250 245
New

We're in Beta

About us Mission Statement