AstonJ

AstonJ

Objects vs Processes

First, listen to Joe Armstrong talk about processes…
(32m14s in)

I suppose when you put it like that - it makes total sense. But the funny thing is when OOP was first explained to me I thought that made perfect sense :043:

Does anyone else feel like they are being torn between universes? :lol: It’s actually a fascinatingly new experience for me!

But back to the topic - do you think in processes?

Most Liked Responses

Korbin73

Korbin73

This might get long-winded… Joe makes some incredibly valid points. Like you, when I first learned OOP, it made perfect sense to me. But does it? If you have a bike object, does it make sense that it has a method called bike.ride() on it? Or does it make more sense that an action is HAPPENENING to it like ride(bike)?

In a hotel reservation system, does it make sense that a customer is being modeled like this: customer.check_in()? Or does it make more sense that something is being done to the customer like check_in(customer)?

I had always struggled with the mental model of having a model with actions on it even though I have been in OOP languages for 16 years. It ALWAYS made more sense that something gets done to a model than a object(model) taking action. At the time I learned OOP I knew it “didn’t feel right” but I continued to model my program in such a way where an object gets “injected” (in a loose way) into another object and the model is actually what “takes an action” instead of an action being done to it because that’s how I learned you are supposed to do it. I believe this is the part that Joe is referring to that “defies the law of physics”. Does it makes sense to inject a car rental object into a reservation object so the customer can reserve a car? Or does it make more sense for the reservation process to send a message to the car rental process to reserve a car? I would even go as far to say that OOP is a failed model. Actually, let me rephrase… OOP without message passing is a failed model.

When I talk to programmers and they say that OOP fits their mental model better than functional programming, the first thing you have to ask yourself is if they are saying that because it’s true? Or are they saying that because the only paradigm they have learned is OOP and it’s all they know? By definition, you have try more than one thing to know if it is a better fit for you :slight_smile:

uranther

uranther

And if you program it in NodeJS, your brain will melt!

:043:

In the PHP/Java world, you most definitely need a getter and setter for (almost) every one of those properties, or you are violating the OOP directive. I think this is what Rich Hickey means when he complains about OOP “ceremony” - it is an utter waste of time. Then you get into object reflection when you need to write tests or deal with a broken/leaky interface, and then it really starts to feel as if you are doing something fundamentally wrong. OOP never really made sense to me, but everyone was doing it, so I had to follow along in my work.

sashaafm

sashaafm

Where Next?

Popular in Discussions Top

Donovan
Hello everyone, I’m so glad to have discovered this awesome community. Thanks for creating it! This is my second post, and apologies for...
New
jeramyRR
This is an interesting article to read. Elixir’s performance, like usual, is excellent. However, it seems like the high CPU usage is co...
New
thojanssens1
It would be nice to be able to define a redirect from one route to another from the router.ex file. E.g.: redirect "/", UserController, ...
New
WolfDan
After doing a port from a c++ library to my project in phoenix I’ve seen that I need a faster way to run this algorithm and I found this ...
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
crabonature
I’m still quite new to Elixir. As I understand we got in Elixir “multi guards” as convention to simplify one large guard with or’s?: de...
New
opsb
We’re considering our architecture from a viewpoint of scaling our traffic heavily over the next 6 months. Our current deployment is runn...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
Markusxmr
Since Drab has been developed for a while in the open, introducing the Liveview functionality in a way it happend appears to undermine th...
New

Other popular topics Top

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 43622 214
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
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
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
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement