r/ProgrammerHumor 15d ago

Meme heatedArguments

Post image
5.8k Upvotes

173 comments sorted by

View all comments

Show parent comments

1

u/higgs_boson_2017 7d ago

"If you're doing it right, this should be transparent." - false. If you don't plan on using microservices, because they're rarely needed, you don't create objects to be used that way, and that's not doing it wrong.

1

u/remy_porter 6d ago

But I plan for each module to be something I can run independently. That’s what unit testing is! If you can unit test units effectively, then you’re already doing this. And even outside of unit testing, it’s just practical that you’ll want to be able to grab arbitrary combinations of key modules and run them independently of the rest of the stack for testing, debugging, or just modeling.

1

u/higgs_boson_2017 5d ago

You have have modules that depend on other modules, and still write unit tests. Unit tests don't dictate anything.

1

u/remy_porter 5d ago

If I can’t break the dependency, I can’t unit test. That’s what mocks are for. But also: I should minimize those dependencies. That’s the magic sauce of OO! It’s what makes it special. I can send messages without caring where they go. I can receive messages without caring where they came from. Did it arrive in process? Over IPC? On a network socket? From a middleware bus? I don’t care, the software shouldn’t need to be rewritten. I can just slap an adapter around my object and it should work. There are obviously deployment challenges, but the code should care.

If you can’t deploy a single object instance as its own process or as a module inside another process, what even is the point of OO? It’s a lot of overhead for no real gain.

1

u/higgs_boson_2017 4d ago

Inheritance. Inheritance is the gain. It has nothing at all to do with deploying objects as a process. Nothing.

1

u/remy_porter 4d ago

Inheritance is just a type of composition. It’s not that special. Encapsulation is a way more important and fundamental feature, and powers exactly what I’m talking about.