smedegaard

smedegaard

I’m pretty new to Elixir. I’ve read some books, done a Udemy course, done some exercism and hackerrank problems and started on a Phoenix app.
I was a happy camper, but following the Elixir buzz on this forum, Elixir Fountain and other places I started getting the feeling that the “1.2 way” of doing Phoenix apps was kinda frowned upon by some people.
So I stopped development on my Phoenix app and read a bit more about OTP, watched Chris presentation of Phoenix 1.3 a bunch of times, bought and started reading Lance’s new prag prog book and tried to apply those thoughts and ideas to my app.

Now i bassically feel like a poor noob that is getting told that

“You probably don’t need a database”

But I really can’t see how anything else but a live session kinda thing like a game or a chat could work without persisting data in a database.

Am I misunderstanding this totally? Are there any other poor noobs out there that are getting the same vibe?

Showing Posts 40 to 31

AstonJ

AstonJ

@NobbZ’s post sums it up for me:

If it’s data you don’t mind losing in case of a system/power failure (such as temporary user settings) then there’s a good argument not to persist. But if it’s something like User account details, then I would persist.

Also, as you’re interested in application architecture I highly recommend PragDave’s online course - it’s sparked some really interesting discussions about approaches to development in Elixir.

yial2

yial2

I am reading the same book(functional-web-development-with-elixir-otp-and-phoenix) and this exactly what I am feeling like recently. Initially I was really excited because I feel like it can be a huge performance gain since there is no more back and forth between code/logic and database.

I also ask some questions regarding my specific need on elixir-lang IRC. The specific conversation can be found here beginning 4:06PM between users yial2(myself), @radar, and Zarathu. The preliminary is that GenServer process may not be suitable for my need, but I am still doing some more reading to try to find out more on my own.

smedegaard

smedegaard OP

Thanks!

cdegroot

cdegroot

Don’t forget, Kernel.put_in/3 is your friend when doing nested structs :slight_smile:

(and the only reason that I’m mentioning this is that I had a hard time finding it in the docs when I needed it…)

smedegaard

smedegaard OP

Thanks again.

That’s actually what I started doing yesterday. With one eye on “To spawn or not to spawn” and one eye on the Functional Web Dev book I began making modules with structs to represent my contexts/units. Let’s see where this leads :+1:t2:

easco

easco

I agree with you. There doesn’t really seem to be any reason to put those things into an Agent or process in-of-themselves. They could just as easily be crammed in a struct:

defmodule StrangeBrew.MaltProfile do
  defstruct name: "", base_malt: :two_row, specialty_malts: [], lovibond: 100 # etc

  def to_string(profile), do: "#{profile.name}(#{profile.lovibond}˚L)")
end

By the same token there’s not any particular reason to start out by tying them to a database. In the future, should you want to try some fancy stuff (say estimating Lovibond from the particular grains in the profile) you shouldn’t have to “contaminate” your estimation logic with a bunch of stuff related to database queries and the size of table columns.

smedegaard

smedegaard OP

I guess what I’m struggling with is see nice pure functions and modules for this use case.

My mind is in object ↔ Database land…

Take malt_profile. It would have a name and some attributes like colour and such. I can’t imagine that cramming stuff like this in an Agent or Process would have any benefits.

There’s no real time commutation going on. The only thing a malt would ever do is being a part of a malt_profile. And that in turn, would only be part of a recipe, which would be part of a batch.

No game dynamics. No chat. Nothing fancy (yet)

smedegaard

smedegaard OP

yeah. I agree. But I’m too much a noob to take all of this stuff in in one go…

Qqwy

Qqwy

TypeCheck Core Team

I think the ‘contexts’ that Phoenix 1.3 is introducing are very much in line with the “create an interface for your app’s business domain and implement it for the persistence piece(s) you are considering.”, in that the context module is the only place where the business domain layer and the technical layer meet.

smedegaard

smedegaard OP

So I guess I’ll just post it here and see what happens…

Basically users have recipes
a recipe have a yest_profile, malt_profile, mash_schedule, hop_profile and adjuncts
a batch will have a recipe, brew_date and other batch spekecific data points
I’m thinking that there should be both public and private repositories for malts, yeasts and hops

I have some other features in mind, but let’s leave that out for now.

If I was to “go the Uncle Bob way” and leave persistence out of this for as long as possible, how would I do this?

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
aseigo
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews