The difference is that a service might do many things, while functions and variables usually have smaller purpose.
If you are putting random functions into a service to the point where you can't even pick a descriptive name, that sounds like you've got bigger problems.
This is similar to running multiple services on the same host, but clients don’t use the canonical hostname, but service-specific subdomain names.