One connection with n operations or n connections with one operation?

I was helping forcefully a friend learn OOP, by rewriting a module of theirs into an OOP module, because the thing he was trying to achieve was the exact thing you’d use it for. There was one element of his script that had me pondering though, and it looked something like this:

local Objects = {}
task.spawn(function()
	Runservice.Heartbeat:Connect(function()
		for i,v  in Objects do
			if ... then  
				...
			end
		end
	end)
end)

In short: He had a table of non-OOP objects (Objects), with heartbeat connection that’d iterate through all the objects, but my intuition tells me that this would be an unorthodox way of operating an OOP module, but at the same time, if he had made a heartbeat connection for each object individually in an actual OOP module, would that be less efficient, if so, by “how much”?

function Object.new()
	local self = setmetatable(...)
	self._Loop = Runservice.Heartbeat:Connect(...)
end

I guess this just boils down to how connections work at a low level

Generally, the second example is better as it provides better maintainability due to the fact that the objects own the behaviour and state which is encapsulation, a core principle of OOP. However, performance-wise, the first one is better as more events means more overhead.

Many times the solution happens to be somewhere in between, each connection running each own batch of operations. You can think of it as one dimensional variable on the number line, at the start you have one connection doing all the operations, at the end many connections doing one operation each. Now around the middle of that line, you have magic going on. Welcome to parallel programming.

That makes sense, come to think of it, I think I’ve written a shop module that does exactly this to handle purchasing requests lol