apoorv-2204

apoorv-2204

How a simple problem like of inheritance or any other problems are mapped to functionalD and in OOD , what are their differences in their design model.?

If we been given a problem let say x to design and model it.How it would differ for the OOD and FD?

Lets say for entities like Person, Man, Woman , Father ,Mother, lawyer student?

How we design a future proof software? How we deal differently , with maybe upcoming future complexity in software? for both the designs?

Like in more complex situation like designing of vending machine , parking lot ,etc.How those OOD maps to functional. In functional there are just transformation of data.

Showing Posts 1 to 8

adamu

adamu

Program maintenance is an entropy-increasing process, and even its most skilful execution only delays the subsistence of the system into unfixable obsolescence

– Fred Brooks

:slight_smile:

apoorv-2204

apoorv-2204 OP

what if we build Minecraft in elixir?

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

There have been quite a few FP vs OO threads lately, I would consider reading through and contributing to one of those instead of starting a new one. Topics tagged functional-programming

D4no0

D4no0

What if we build elixir in minecraft? :joy:

apoorv-2204

apoorv-2204 OP

thats awesome.

imagine meme
get this man a shield
you didnt have to cut me off meme
brain exploding meme.

ps: I cant post meme, I will get banned

olafura

olafura

For this specific example of Person then I would look into Protocol. It focuses on what functionality you need from the data structures you have.

I’ve always been a bit puzzled by teaching OOO as you have a base class of Animal and then have it inheriting from that. Because it’s the wrong lessons often and makes people over engineer their designs.

Classes are about how you store things in memory and you use inheritance to be able to access internal structures.

Elixir is very nice for a flow processing where you have a structure and are modifying in each step, eg:
JSON |> Struct |> Email message |> Send Email

With Elixir and other functional languages you know can know exactly where a problem originated while with Classes you are sort of scratching you head and wondering how did this variable get messed up.

For something like vending machines it’s just a state machine and I feel like it fits better than Classes.

LostKobrakai

LostKobrakai

Ducktyping can work well in functional programming. E.g. take elixirs datetime handling. You can do DateTime.utc_now() |> Time.to_iso8601() and it will work, because the fields Time.to_iso8601 expects are a simple subset of the fields %DateTime{} holds. No need for any inheritance.

adw632

adw632

Some essential rules:

  1. Let data be data.
  2. Use CRC (Create, Reduce, Convert) pipelines. Most things in elixir and FP is essentially reducing over some state.
  3. Use modules to organise related functions that operate on some state.
  4. If you wish to compose use import or delegate to other functions in other modules.
  5. If you want polymorphic behaviour use protocols
  6. If you want to derive functional behaviour with your own overrides use behaviors

Look at the Enum module, it can work on data elements of any type, so think in terms of steps or an algorithm and really let the data be just data.

For true OO semantics look at Elixir process modules such as genservers or liveviews which are objects as per the Alan Kay definition, they accept messages as the only means of interacting with them and manage private state in their own process context.

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4663 61218 595
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
515 12931 101
New
wmnnd
Hey folks, I wanted to share with you a project I’ve been working on for a while: It’s an Open Source (AGPLv3) newsletter tool. Think Ma...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
sntran
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New
gtcode
I’ve been tinkering with Lynx (by José) via hold_ledger. I used AI to write the code, a separate specification, the tests, and the Lean p...
New
Ganna
Hi everyone, I have 8 years of production experience with Erlang/OTP and I’m just starting to get to know Elixir. What would you learn f...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews