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 dennismv2004-12-30 06:44:05
  The first could be written... by jdelphiki2004-12-30 07:49:52
    Bzzt, Try again. by fudje2004-12-30 07:55:53
      We don't know about x() or y()... by jdelphiki 2004-12-30 08:50:13
...so I assumed that the condition() was something that operated independently of the functions.

From the code given, I would say it's a fairly safe assumption because it would be bad form for x() to change condition() while it can be executed from both outside and inside of the loop.

The problem is that x() ends up controlling the loop, rather than the loop controlling itself. The encapsulation of the x() functionality isn't very well defined if x() sets condition() for the loop, and can be executed inside of the loop and independent of it as well. The loop would end up being dependent on some logic that's occurring in x(), which determines whether or not it should execute y() and, subsequently, x() again. It seems awkward that way.

The counter analogy was simply supposed to show what the loop might have looked like if condition() had been based on some counter value. The pre-execution of x() would likely have required presetting the loop's counter to reflect the first iteration outside the loop.

It's hard to say which way, of all the methods discussed, would be the best, not knowing what's in x() or y(), but I guess that's my point. In a perfect coding world, the loop shouldn't have to know or depend on knowledge of what's in x() or y() to be able to run properly.
[ Reply ]
        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

 

[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.)