5/8/2008 7:29:04 PM
5/8/2008 7:37:19 PM
Some people use For loops for everything. I use While (or Do as syntax may decree) loops for everything. They are functionally equivalent.
5/8/2008 8:33:43 PM
functionally equivalent, yes. legibly equivalent, in the OP's case, no way.
5/8/2008 9:44:21 PM
i prefer GOTO
5/8/2008 10:08:51 PM
recursion with a counter
5/8/2008 10:48:11 PM
i've been made of fun of for exclusively using while loops...never really used for seriously
5/9/2008 12:15:09 AM
i use reflection for everything
5/9/2008 12:19:57 AM
I might be very wrong, but I always divided whether I used for/and while depending on 1. whether i needed access to the counter2. whether i'm testing for a condition that is not strictly a counter (EOF, hasNext() exists() whatever)
5/9/2008 11:44:54 AM
that sounds about right
5/9/2008 11:51:05 AM
while(1) {sleep(5);}
5/9/2008 12:01:24 PM
^^^^^^^ My supervisor has said he would fire someone on the spot for using a GOTO. I know the pain of dealing with their code, we usually get paid to fix it
5/9/2008 4:08:04 PM
if ( someboolean == true){return true;}else if (someboolean == false){return false;}
5/9/2008 5:12:19 PM
5/9/2008 6:09:04 PM
i dont see that big of a deal with using a post-conditional with instead of a pre-conditional.
5/9/2008 6:24:34 PM
sometimes you just need something to execute at least once ok
5/9/2008 9:35:22 PM
yeah i actually relish the opportunity to use a do while
5/9/2008 9:49:43 PM
I remember one at my last job went through and changed a bunch offor (int i = 0; i < ??????; i++)to for (int i = 0; i < ??????; ++i)for no apparent reason
5/9/2008 10:11:08 PM
ya'lls a bunch of nerds
5/9/2008 10:28:40 PM
^^ Because pre-increment is more efficient than post-increment because it doesn't create a copy. Granted for built-in types like int in the example you showed the compiler will optimize it out, but for more complicated objects that define ++ (and also --) and for iterators pre-increment is definitely what you want to do if you simply want to increment a value.
5/9/2008 10:59:23 PM
i prefer
5/9/2008 11:39:17 PM
Jaeger out of nowhere with a quality post as usual
5/9/2008 11:58:29 PM
Definitely quality, but like he said, it shouldn't end up making a difference. It might not even make a difference for more complicated objects (guess that depends on the compiler) since the result of i++ isn't really consumed by anything.[Edited on May 10, 2008 at 1:30 AM. Reason : makes me wonder why the convention is to postfix in for loops though]
5/10/2008 1:22:44 AM
5/10/2008 10:46:48 AM