Whitespace and snow blindness

From: Date: Thu, 16 May 2002 14:04:01 +0000
Subject: Whitespace and snow blindness
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6139@lists.php.net to get a copy of this message
Sebastian, will you please visit less Java lectures and university? This hurts, really, not only in my eyes, but also deep inside my brain. My code: - if ($this->_debug) - syslog(LOG_DEBUG, "ctor (will start):".serialize($this)."\n"); After visiting the indentist: + + if ($this->_debug) { + syslog( + LOG_DEBUG, + 'ctor (will start):' . serialize($this) . "\n" + ); + } + My single line of code: - $r = sprintf("Stackdump (level: %s) follows:\n", $this->_level); Your reformatting, covering half the gobi desert: + $r = sprintf( + "Stackdump (level: %s) follows:\n", + $this->_level + ); What was once a readable formatting: - for ($i=$this->_level; $i>=0; $i--) { - $r .= sprintf("level=%d\n", $i); - $r .= sprintf("element=%s:", $this->_elementStack[$i]); - $r .= sprintf("%s\n", - htmlspecialchars($this->attributesToString($this->_attributesStack[$i])) - ); - $r .= sprintf("cdata=%s\n\n", - htmlspecialchars($this->_cdataStack[$i]) - ); - } - return $r; Now spread out over 1 1/2 screens: + for ($i = $this->_level; $i >= 0; $i--) { + $r .= sprintf( + "level=%d\n", + $i + ); + + $r .= sprintf( + "element=%s:", + $this->_elementStack[$i] + ); + + $r .= sprintf( + "%s\n", + htmlspecialchars( + $this->attributesToString( + $this->_attributesStack[$i] + ) + ) + ); + + $r .= sprintf( + "cdata=%s\n\n", + htmlspecialchars( + $this->_cdataStack[$i] + ) + ); + } + + return $r; Boy, you really need some time with a K&R compiler and a 80x25 vt100. In earnest: Properly indented code is good. Whitespace where appropriate is good. But, code that is a side dish (like syslog debugging statement) must not be formatted such that it gets into the way of understanding the actual meaning of the main code. Really. Now please open that 80x25 konsole, black background, green text and try to read and understand the above code. And then reverse these patches. Kristian -- http://www.amazon.de/exec/obidos/wishlist/18E5SVQ5HJZXG

« previous php.pear.dev (#6139) next »