Richard Lynch schrieb:
On Tue, May 2, 2006 3:02 am, Barry wrote:
Rafael schrieb:
    IMHO, vertical aligned brackets can be messy when nesting
relatively-small blocks (and seems to me like a lot of wasted space)
Huh?!
Show an example. I don't think you will be able to show one.
But this wasted space gives you a lot more insight into the code when
looking for loops,whiles,functions and such.

if (...)
{
  if (...)
  {
    if (...)
    {
      //blah
    }
    //blah
  }
  //blah
}

Sorry, where is this here better?
if (...) {
  if (...) {
    if (...) {
      // blah
    }
  //blah
  }
//blah
}

And then it goes like:
if (...) {
  if (...) {
    // mmh
  } else {
    // oh
  }
  while (...) {
    if(...) {
      // oh
    } else {
      if (...) {
        // where am i?
    } else {
      // huh!?
    }
      // hmm
    }
  if (...) {
    if (...) {
      // blah
    }
  // blah
  }
// blah
}
The same as above in the other style:
if (...)
{
  if (...)
  {
    //mmh
  }
  else
  {
    //oh
  }
  while (...)
  {
    if (...)
    {
      //oh
    }
    else
    {
      if (...)
      {
        //where am i?
      }
      else
      {
        //huh!?
      }
      // hmm
    }
  if (...)
  {
    if (...)
    {
      // blah
    }
    // blah
  }
  // blah
}

I know you could use elseif, but it's okay like this for presentation.

I bet you would have problems coding so much nested IFs or such, i did had them writing that first style above.

Bzzzzt.

Without indentation, it's just garbage.

I've seen ppl coding like that.
And using that inline bracket method just makes it so hard to read.


If you indent, you see it as you scroll through without actually
"reading" it no matter where you put the braces.

I give an example.
Probably you see for yourself what of those would be rad better and "faster" (^_^)

Your style:
function findetag() {
        $wochentag = func_get_arg (0);
        if (func_num_args() >= 2) {
                $letztezeit = func_get_arg (1);
        } else {
                $letztezeit = time();
        }
        $count=0;
        $taggefunden = false;
        while (!$taggefunden) {
                $count++;
                $tagarray = getdate($letztezeit);
                if (strtolower($wochentag) == strtolower($tagarray["weekday"])) 
{
                        $taggefunden = true;
                } else {
                        // tag drauf
                        $letztezeit = $letztezeit+86400;
                }
                //endlosschleife abbrechen
                if ($count > 20) {
                        $taggefunden = true;
                        $letztezeit = false;
                }
        }
        return $letztezeit;
}

My style:
function findetag()
        {
                $wochentag = func_get_arg (0);
                if (func_num_args() >= 2)
                        {
                                $letztezeit = func_get_arg (1);
                        }
                else
                        {
                                $letztezeit = time();
                        }
                $count=0;
                $taggefunden = false;
                while (!$taggefunden)
                        {
                                $count++;
                                $tagarray = getdate($letztezeit);
                                if (strtolower($wochentag) == 
strtolower($tagarray["weekday"]))
                                        {
                                                $taggefunden = true;
                                        }
                                else
                                        {
                                                // tag drauf
                                                $letztezeit = $letztezeit+86400;
                                        }
                                //endlosschleife abbrechen
                                if ($count > 20)
                                        {
                                                $taggefunden = true;
                                                $letztezeit = false;
                                        }
                        }
                return $letztezeit;
        }

On "first" view i can clearly see what is happening without going "through" the code.


I frequently code on smaller monitors -- laptop, ancient desktop,
stripped-down flat-panel monitor that fits inside a rack-mount 2-RU
shelf in my sound booth...
Yes, and some people actually code on PALM handhelds and i have seeing ppl coding on mobile phones. There won't fit your 80 chars per line style. Are you going to strip it down to 13 per line now because of that?

Yes you can actually code it that it fits in any small space so that you might even see it on a digital watch.

But that fact shouldn't be affecting coding style at all.

I can't really lug a 19" monitor all over, and there's no room in my
sound booth for it, what with the amps, sound boards, computer, CD
duplicator, etc.

See, that is not a problem of cofing style it's a problem of you having no space to code.

Yeah even i might start coding as compact as possible sitting in a narrow room with a 10" LCD laptop.

But i think i would just give up coding.
That's IMHO no way you can code good in such places.

barry
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to