Comment by vips7L

4 days ago

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.

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.

  • 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.

    • 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.

      3 replies →

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.