Carey Brown wrote:They ARE clearly indicated because they only reside inside the KeyboadInputs utility class.
Yes, but you won't be able to tell that your code is using the KeyboardInputs
class just by looking at method signatures. This can lead code maintainers to make wrong assumptions about code they didn't write, and make it difficult to test and easy to introduce new bugs.
Even if you're writing code just for yourself, and you think passing services to constructors/methods is onerous, I don't think it's a good thing to teach this to beginners.
Do you not consider STDIN a constant?
No. Standard input produces different results upon different method calls. By definition, it is not constant. Assigning non-value types to globally accessible variables is one of the biggest contributors to buggy spaghetti code.
Campbell Ritchie wrote:How could you avoid that? If anybody writes new Scanner(System.in) anywhere, you are up the creek without a paddle anyway.
Yes, and it's a shame that the Java designers chose to make standard input available through a static field, instead of an application context injected into the main method. But is that a good argument for adding even more static references to non-value types to your application? You're just adding different ways for your application to access standard input unexpectedly.
Can either of you tell me why you think this is so terrible?