Depends on a few things ...
1) Use . Do you want to say MyClass.getClient () and get a link to a client variable? If you are aiming for a singleton thing - yes. If you are aiming for a very convenient thing - yes, if it is safe, if you just want it to be visible everywhere - no. If access to it from the wrong place / time causes failures and errors - no.
2) People People will use everything that you exhibit, period. If they see that your code is being selected by the client this way, they will use it when it is unacceptable, so that will cause a lot of errors? :)
3) Design Do you really need it? Is it cleaner to pass as an argument than to have absolute access to it at any time?
Once you evaluate it, you decide. It looks like it builds and works great. But anything that requires this kind of unlimited access (at any time specified above) to runtime specifications may not be the best approach; what works for homework may not be for enterprise software.
Shark source share