Honestly, I found access to a friend that came from C ++ to be a symptom of poor design. You better fix your design.
For starters, who really cares, does anyone create a user? Does it really matter? I ask this because it seems that sometimes we programmers get carried away with something that simply won’t happen, or if they do, it doesn’t matter.
If you really don't care, do one of the following:
- Make user interface. The server can create an instance of a private class that implements it; or
- Make the user an internal class of the Server without public designers, so only the server can create it.
The visibility of hacks (of which friends in C ++ are one, and batch access in Java are both good examples) just ask for troubles, not a good idea.
cletus
source share