News for hackers. Stuff that matters.
Re:Fifty Shades of OOP by vips7L on Tuesday November 25, 2025 @12:57AM (#46042751)
Service classes are the thing I hate most. They’re just namespaces for functions. They’re a product of Java not being able to have top level functions.
Re:Fifty Shades of OOP by elric on Tuesday November 25, 2025 @02:34AM (#46043258)
Not being able to have top level functions is a feature, not a bug.

You can declare static methods on interfaces in Java, which means you could call things like Users.create("Foobar") if you wanted to.

Re:Fifty Shades of OOP by vips7L on Tuesday November 25, 2025 @03:54AM (#46043800)
It is not a feature. Every programming language since has decided this was a mistake.
Re:Fifty Shades of OOP by elric on Tuesday November 25, 2025 @04:54AM (#46044222)
Can you provide an example of that?
Re:Fifty Shades of OOP by fmjrey on Tuesday November 25, 2025 @06:12AM (#46044719)
Here is an example of a 2006 rant that qualifies: https://steve-yegge.blogspot.com/2006/03/execution-in-kingdo...

OO conflates many different aspects that are often orthogonal but have been conflated together opportunistically rather than by sound rigor. Clearly most languages allow for functions outside classes. It's clearly the case today especially with FP gaining momentum, but it's also clear back then when Java and the JVM were created. I think smalltalk was the only other language that had this limitation.

Like others in this thread, I can only recommend the big OOPS video: https://youtu.be/wo84LFzx5nI

Re:Fifty Shades of OOP by javcasas on Tuesday November 25, 2025 @04:32AM (#46044055)
Not everything can be associated to a single entity. Many operations work on two or more entities where none of them are the "master". Otherwise you end up with "coordinators".

Users.create(...) is the easy case. Try transfer_permissions(user1, user2, entity) while retaining transactionality and the ability of either user to cancel the transfer.

Re:Fifty Shades of OOP by elric on Tuesday November 25, 2025 @04:43AM (#46044141)
Permissions.transfer(x, y, z)

I'm not sure why having a global function by the same would make this any easier or harder to implement. But it would pollute the global namespace with highly specific operations.

Re:Fifty Shades of OOP by javcasas on Tuesday November 25, 2025 @05:37AM (#46044520)
And now you have invented a helper class when all you needed is a namespace. And you already had namespaces.
Re:Fifty Shades of OOP by elric on Tuesday November 25, 2025 @06:58AM (#46044984)
It doesn't have to be a class. It can be an interface. And regardless of what it is, it has to go somewhere. Whether it's in assorted_functions.c or Permissions.java makes little difference.

I mean it makes sense to group "like" things together. Whether that's in a module, a class, an interface, or a namespace. Having a huge number of things globally is just confusing pollution.

Re:Fifty Shades of OOP by javcasas on Tuesday November 25, 2025 @07:31AM (#46045188)
> it has to go somewhere

Yes, but going as a static method into a class that goes into a module is overkill vs just putting it in the module.

> Having a huge number of things globally is just confusing pollution.

I don't know what language you use, but modern programming languages allow specifying what to import when importing a module. You don't have to import everything from every module.

Re:Fifty Shades of OOP by morshu9001 on Tuesday November 25, 2025 @10:13AM (#46046479)
They're just namespaces for functions, and... why is that so bad? Of all the reasons I hate Java, this isn't one of them, it's whatever.