I've been doing Java now for a month or so, and I was pleased at being able to write:
without looking at the book. But this pleasure was short-lived. My instructor says:
Though there is no explicit rule saying that main should take a parameter called "args", that is the convention, and straying from well-established conventions may cause other programmers to think a bit extra about your code.
I pleaded as follows:
"I started learning Java from SAMS Teach Yourself Java 6(in 21 Days) (The parenthesized bit of the title isn't true of course ). It's from that book that I learned to write arguments and, to tell you the truth, I like it. Args reminds me too much of Aaarrrgh!!!... (several times over) while arguments tells me exactly what it is and seems to me, therefore, eminently more readable (if it's readable code we're after) than args... and if, as you say, it causes other programmers to think a bit extra about my code... Is that really such a bad thing? Shouldn't programmers be good at that (???)" ----------------------------------
I am now wondering why the author of the SAMS book chose for arguments when the rest of the world (apparently) uses args? I appreciated it, as being immediately understandable and see no reason to stick to convention, in this case.
Interesting. I, too, paused momentarily when I read "arguments" rather than args -- just because I'm soooo used to seeing args that anything different is sort of distracting (even the argv identifier that C/C++ programmers frequently use). On the other hand, I didn't really stop and think as much as I would have if I had seen (String x), so I went on to other things.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Joined: Oct 04, 2007
Funny you should say that, Marilyn, because as I was typing that last night, I thought: "shall I bother, It's not as if they're saying String xyz" (I made xyz of your x) but, I carried on and at least got it off my chest for the time being...
Dick [ October 19, 2007: Message edited by: Dick Summerfield ]
Marilyn de Queiroz
Joined: Jul 22, 2000
Perhaps as you get more familiar with reading and writing Java, you'll feel more comfortable using args.
Funny how certain things will make code harder to read for people. For me, the use of "foo" and "bar" in code samples and also exams makes the code almost impossible for me to comprehend. Because foobar means what it means, my mind just goes all foobar. Reading any code with variables or even classes named foo or bar just messes me up. Wierd.
A few months ago I had an exam where all the code examples were in Norwegian, and they simply translated (most of) the variable names into English in a separate place in my version of the exam. I seriously wished that whoever created that exam would wake up the next day with pustulent boils all over their body.
It was insanely difficult to figure out what the code was saying, even though I had the translated words available. The code just didn't gel. I spent the first hour trying to piece together the program in my mind. Then I frantically spent the last two hours solving the exam problems.
I believe that "thinking about code" is something that I am fairly good at - but it seems like such a waste to have to think about what a variable <code>znh</code> might be holding (not that <code>arguments</code> caused me to pause more than a second).