Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
Dieter Quickfend wrote:I would recommend to always use the "i=i+1" notation for clarity.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote:There is nothing unclear about i++;
There is however no end of scope for confusion when you use i++ as part of another statement. You need to be very careful whenever you do that.
Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
Dieter Quickfend wrote:Anyone with basic math skills will understand "i=i+1".
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Dieter Quickfend wrote:Anyone with basic math skills will understand "i=i+1".
Mike Simmons wrote:
Dieter Quickfend wrote:Anyone with basic math skills will understand "i=i+1".
Mmm, from a basic math perspective, that simply looks like a false statement. It implies 0 = 1, and no value of i can make that true.![]()
More to the point though, I can accept "use i = i + 1" as initial advice for beginners, OK -- but if they finish the course thinking it's always preferable, or if they finish and still think i++ or i += 1 are in any way hard to read... well, they've got a lot more studying ahead before they'll be able to work productively.
Now personally, I will happily use +=, -=, *=, /=, &=, or |= on the rare cases that they make sense. I will concede that all but the first of those are a bit unusual to see in code, and that may be a valid reason to avoid them. But for professional work, anyone who can't at least read +=, easily, really needs to be dropped from the team.
Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
Dieter Quickfend wrote:I simply mean that clarity is always preferable over brevity...
There is no excuse for using "i++" anywhere in an enterprise application (except the occasional for loop).
There are many things I will avoid in an enterprise application, including the increment operator (except for the classic 'for' loop) and heavy use of the switch operator...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
Dieter Quickfend wrote:What I'm saying is that if you find yourself in a position where that difference determines whether your application is functional... you've already lost the technical debt match. There is nothing easier to miss than that. You will read it twenty times, and even knowing the difference, you won't notice it.
Very interesting discussion though. It seems that no one agrees with me on the increment operator, which I find surprising.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
|