Iterating over an array style question

A

Arne Vajhøj

Either of whom ought to be able to remember that in Java, order of
evaluation is always left to right. Especially since the subset of
maintenance programmers who have not read the JLS had better be {Ø}.

But it isn't.
How can you trust someone to maintain programs in a language that they
do not know?

You may trust them, but if they get assigned the task then ...

Arne
 
A

Arne Vajhøj

These are tables with forms of some important italian verbs:

http://www.italian-verbs.com/italian-verbs/conjugation.php?verbo=essere
http://www.italian-verbs.com/italian-verbs/conjugation.php?verbo=avere
http://www.italian-verbs.com/italian-verbs/conjugation.php?verbo=dovere
http://www.italian-verbs.com/italian-verbs/conjugation.php?verbo=volere
http://www.italian-verbs.com/italian-verbs/conjugation.php?verbo=potere

They are irregular, there are several dozens of other common
irregular verbs and about 10000 - 30000 words with different
forms (there are »irregular« nouns, too) that one is
expected to learn by heart when one wants to learn Italian.
When listening or speaking, one then needs to apply all the
rules and all this knowledge in real time.

Now, what amount of information does the Java operator
precedence table contain?

http://download.oracle.com/javase/tutorial/java/nutsandbolts/operators.html

So, can we reasonably expect people with a paid job as a
programmer or Java programmer to learn or at least look up
at this URI the precedence of operators when they need to
know this to understand a part of some source code and
usually will need this knowledge every day?

The comparison between natural languages and programming
languages are always fun. There are some differences
though in context.

But it is probably more difficult to learn Italian than
Java.

(and more difficult to write good novels in Italian than
to write good programs in Java as well)

And I am sure that there are people trying to speak Italian
without having learned all those irregularities just like there
are people writing Java with some pretty big blank areas.

My usage of "German" would make most teachers in German cry!

One of the differences between irregularities in Italian and
operator precedence in Java is that the first is unavoidable
while the second is avoidable.

Which was my original point: it is good programming to use
parenthesis's so that even those that has not learned the
operator precedence rules understand the expression correct.
Parenthesis's are rather cheap.

That + a general understanding of operator precedence concept +
ability to find the Java rules if necessary is what in my opinion
characterize a good Java developer.

Having memorized the Java rules is just a gimmick.

Arne
 
M

Mike Schilling

Arne Vajhøj said:
But it isn't.

Someone who needs to maintain programs written in N different languages
won't be an expert in all of them, if only because someone with that much
ability wouldn’t be a maintenance programmer.
 
T

Tom Anderson

Here's an interesting example from JLS ?15.7 which makes clear how
evaluation order and operator precedence are quite different:

class Test {
public static void main(String[] args) {
int a = 9;
a += (a = 3); // first example
System.out.println(a);
6!

int b = 9;
b = b + (b = 3); // second example
12!

System.out.println(b);
}
}

prints:

12
12

Huh. You learn something new every day. On reflection, i'm glad it's 12,
because it means, i think, that a += b is always equivalent to a = a + b,
which strikes me as a good thing.

Personally, i never use += (except occasionally in for loop update
clauses), precisely because it trips up people who don't know every detail
of the language, like me.

tom
 
T

Tom Anderson

The Java Code Conventions were last modified in 1999.
They also contain other advice that obviously is bad:

?Methods should be verbs (...) runFast();?

http://www.oracle.com/technetwork/java/codeconventions-135099.html

First, ?run fast? is not a verb. ?run? is a verb. ?run fast?
is a verbal phrase.

And an incorrect one - 'fast' is an adjective, not an adverb. It should be
runQuickly, or perhaps runSwiftly.

At least, in English usage as it stood, say, a hundred years ago. Enough
people now use 'fast' as an adverb that it's correct, although to me at
least, it still seems crass.
Next, obviously this advice was not followed even by Sun
engineers, and for good reasons, we have ?main? and ?sin?

If you think 'sin' isn't a verb, you should consult your local priest
immediately!
- not ?run? and (I can't find any verb for a method that is
used to write expressions denotating the sine of a value).

Insinulate. And if it isn't, it should be.
The correct rule in this regard is given by Rob Pike:

?Procedure names should reflect what they do;
function names should reflect what they return.?

I think that's a good rule. Now all we need is for the compiler to be able
to tell verb and noun phrases apart, and to enforce a lack of effects in
noun-named functions, and the presence of at least one effect in
verb-named functions.
http://www.lysator.liu.se/c/pikestyle.html

This, ?sin?, correctly, is a noun, because it names what
is returned.

Although really, under that rule, it should be sine - sin is not a word in
English, it's a mathematical symbol.

tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,127
Latest member
CyberDefense
Top