The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

code styles by dennismv 2004-12-30 06:44:05
Here are 2 versions of code with identical functionality:
//first
x();
while (condition())
{
    y();
    x();
}
//second
do
{
    x();
    if (!condition()) 
        break; 
    y();
}
while (1);
x() and y() may be blocks of code.
Which version is preferred ?
[ Reply ]
  i prefer by stacato2004-12-30 06:50:03
    How about this? by Brainbug2004-12-30 06:52:52
      In the 2nd one x() will always be executed... by kelli2172004-12-30 07:17:59
        Ah, rats. by kelli2172004-12-30 07:20:10
        condition by dennismv2004-12-30 07:22:56
    do{} while() is appropriate when by BloodyViking2004-12-30 07:00:13
      I agree. (n/t) by tom-2004-12-30 07:05:26
      my purpose was to by dennismv2004-12-30 07:10:29
        Well you can always by jayfarm2004-12-30 07:26:12
          I agree by dennismv2006-11-19 12:55:59
    2nd version can have while at the top by dennismv2004-12-30 07:00:14
  First. by Brainbug2004-12-30 06:50:44
    And if x() is a very long section of code, by bwkaz2004-12-30 07:03:21
      It's a function already. by Didactylos2004-12-30 08:56:04
        Yes, but: by bwkaz2004-12-30 16:15:19
    See, I just don't like typing "break" on a Windows by tnglives2004-12-30 07:05:59
      it can be rewritten without break by dennismv2004-12-30 07:17:30
        Flags are evil. by Didactylos2004-12-30 08:53:35
  MUAHAHAHA! by fudje2004-12-30 07:21:33
    you are evil :) by dennismv2004-12-30 07:27:09
      Shoulda' seen that one .... by fudje2004-12-30 07:29:35
        thanks by dennismv2004-12-30 07:32:53
    Not evil enough. by wheresthefish2004-12-30 07:37:16
      aiii by dennismv2004-12-30 07:42:20
      Where do you define FALSE? (n/t) by fudje2004-12-30 07:53:35
        Defined by the compiler. by wheresthefish2004-12-30 07:59:30
          o_O Clearly not my compiler. (n/t) by fudje2004-12-30 08:05:59
            OK, by wheresthefish2004-12-30 08:11:08
      I am impressed. (n/t) by LionsPhil2004-12-30 12:15:21
      You could still make it worse. by Avium2004-12-30 12:30:46
  Easy... by imperito2004-12-30 07:45:47
  The first could be written... by jdelphiki2004-12-30 07:49:52
    Bzzt, Try again. by fudje2004-12-30 07:55:53
      It may. by Didactylos2004-12-30 08:48:19
        Good point... by jdelphiki2004-12-30 08:56:02
          It is one of those rare by Didactylos2004-12-30 09:03:54
      We don't know about x() or y()... by jdelphiki2004-12-30 08:50:13
        in the actual code by dennismv2004-12-30 10:32:09
          It sounds like your example is a special situation by jdelphiki2004-12-30 11:35:03
            What's an A/R purist ? (+a cleaner version) by dennismv2004-12-31 02:41:58
  I'm opting for version 1 by dennismv2004-12-30 08:38:13
    Good choice. by Didactylos2004-12-30 08:50:49
  I prefer: by SnArL2004-12-30 08:58:27
    wow ! by dennismv2004-12-30 10:18:38
  Here's what I'd prefer: by Tars_Tarkas2004-12-30 10:32:58
  The form 'for (x(); condition(); x()) {y();}' . . by HadEnuf2004-12-30 12:30:06
    wow ! by dennismv2004-12-31 02:45:21
  what about this? by korazail2004-12-30 13:58:57
    this will work by dennismv2006-11-19 12:55:59

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)