Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

They're students, of course they ask why.

And while nobody had a nervous breakdown, yes, the need to pass references around extremely redundantly because this language lacks any way to establish a global context and top level non-class variables was a continuous impediment to their ability to accomplish the task.

I've seen some good suggestions in this topic though; I think next year I may recommend a top-level container class that has init called on it one time and can then be referenced in all other class files. It's the closest thing to global variables Java has to offer, and would save them a lot of hardship passing references around for no other reason than passing references around.



Right, yeah that sounds like the task for which I typically use a Singleton:

https://www.digitalocean.com/community/tutorials/java-single...

Things like connections to databases, network resources, motors and those types of things.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: