SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 30 of 30
  1. #26
    SitePoint Guru dagfinn's Avatar
    Join Date
    Jan 2004
    Location
    Oslo, Norway
    Posts
    894
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Selkirk
    That idea stems from the old days of structural programming and "goto considered harmful." In a world of spaghetti goto code, coding gurus talked about routines with a single entry point and a single exit point being highly desirable.

    That argument has won. PHP doesn't even have a goto statement.

    Now, I think the dynamic is a continuum between nesting/indentation and multiple exit points. I feel that adding extra exit points can be clarifying when it helps reduce the amount of nesting in a routine.
    Martin Fowler seems to be saying something very similar in Refactoring.

    Quote Originally Posted by Martin Fowler
    I often find I use Replace Nested Conditional with Guard Clauses when I'm working with a programmer who has been taught to have only one entry point and one exit point from a method. One entry point is enforced by modern languages, and one exit point is really not a useful rule. Clarity is the key principle: if the method is clearer with one exit point, use one exit point; otherwise don't.
    Dagfinn Reiersřl
    PHP in Action / Blog / Twitter
    "Making the impossible possible, the possible easy,
    and the easy elegant"
    -- Moshe Feldenkrais

  2. #27
    SitePoint Guru
    Join Date
    Nov 2002
    Posts
    841
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #28
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    FYI, ?: is not called the ternary operator, rather, it is a ternary operator. A ternary operator is any operator that takes three operands (most operators are binary, and some are unary)

    It's proper name is the conditional operator.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  4. #29
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP doesn't even have a goto statement.
    We could have one though

    Just kidding

  5. #30
    SitePoint Zealot abstraktmedia's Avatar
    Join Date
    Feb 2004
    Location
    Ljubljana
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Remy
    Than write it differently
    PHP Code:
    function get($name)
      {
          return isset(
    $this->cfg[$name])
              ? 
    $this->cfg[$name]
              : 
    raiseError('Cannot retrieve '.$name.' config informations.');
      } 
    -Rémy

    For me this is by far the nicest and cleanest way once you get use to it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •