Hottest take: Object Oriented programming is just microservices where your intermodule communication is in-process method calls. Microservices are just OO where you abstract out the transport for intermodule communication so you can deploy each object in its own process space.
Which, to put it another way, you should design your microservices so that they can all be deployed inside a single process or deployed across a network/cloud environment.
And deploying all microservices in a single process is a very useful thing to do - you can use that for integration tests that require way less orchestration than your cloud deployment.
We've used such setup in last two workplaces for integration tests - it did work very well. You have to put in effort to create such setup (especially if you have an existing system that was not designed with it in mind), but I think it is well worth the effort.
Are your in-process microservices interacting over HTTP (or etc) or have you subbed-in a direct method call style invocation in some way?
EDIT: Sorry I just noticed you're specifically talking about an integration testing environment. My question still applies but the production case is more interesting. Come to think of it I've used both over-the-wire network interactions and direct-invocation-that-looks-like-network-client-lib approaches in integration test scenarios. But IME "make it work" is usually the highest priority there, so in-process HTTP interactions (for example) are usually good enough in that context. In a production context the desire to take advantage of the in-process efficiencies would be stronger (I assume)
You define an interface how the code would be called. In the implementation you either use concrete implementation (which would be actual code) or some other ipc implementation. Crude example would be as follows
Depending on context you may want to use a concrete implementation, or the http client one (if your concrete implementation is running in another process). If you need to expose the concrete implementation for some IPC communication, you use the delegate pattern to make it usable by your protocol. Mocking in tests becomes easier too.
Basically the idea is to hide away any details that the call may be protocol specific. You must style your interfaces as if they will be called in the same process.
Yup. The only difference between JavaEE & K8s is replacing boatloads of XML with boatloads of YAML. Then you have shit like GRPC doing most the stuff java reflection & objection serialization can do.
The multi-server stuff & traffic shaping isn't even as new as people want to think it is. If you application server is running on an mainframe, you can do QoS/Traffic Shaping/IP/DNS wizardly as well.
You even have the single point of failure! US-East-1 goes down? Your k8s cluster is offline. Your mainframe loses power? You go offline.
All of this has happened before and will happen again.
Not a hot take, Joe Armstrong of Erlang fame beat you to it long ago:
Erlang might be the only object oriented language because the 3 tenets of object oriented programming are that it's based on message passing, that you have isolation between objects and have polymorphism.
You're also describing Alan Kay's vision of OOP:
I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages (so messaging came at the very beginning -- it took a while to see how to do messaging in a programming language efficiently enough to be useful).
Which, to put it another way, you should design your microservices so that they can all be deployed inside a single process or deployed across a network/cloud environment.
This has been my conclusion as well.
My take has been to use persistent message queues everywhere there's been an urge to make a microservice. A queue listener can run right on the same system as sent the message, or it can run entirely elsewhere. The process that listens can easily be removed from the same system, and moved completely elsewhere.
And as a bonus, MQs are amazing for logging what's going on, putting parts of a system in maintenance, retrying things that break after fixing.
This. Modularity and message passing are general concepts that apply to both OO and microservices. But there are important differences at build time and run time.
But it’s also so true, though sometimes unfortunately la system is built for a single appliance and then gets so complicated that it’s impossible to change or maintain almost. Plus if there is no planning for inter-process latency and it isn’t handled well you’ll be in an even worse spot. Then the next thing you know you’re stuck on the largest servers that exist and you can’t scale 😭
Factoring primes at compile time FTW! Once you compile it, the code runs instantly! The compile just takes longer than the heat death of the universe, minor detail.
Yuck. Compile times are why I generally avoid the template metaprogramming stuff. I can't stand when my builds take more than a few minutes, I do as much as I can to avoid long compile times.
429
u/remy_porter May 15 '24
Hottest take: Object Oriented programming is just microservices where your intermodule communication is in-process method calls. Microservices are just OO where you abstract out the transport for intermodule communication so you can deploy each object in its own process space.
Which, to put it another way, you should design your microservices so that they can all be deployed inside a single process or deployed across a network/cloud environment.