Re: Re: cvs: php4 /pear DB.php /pear/DB common.phpmysql.php

From: Date: Tue, 05 Dec 2000 07:13:23 +0000
Subject: Re: Re: cvs: php4 /pear DB.php /pear/DB common.phpmysql.php
References: 1  Groups: php.dev php.pear 
Request: Send a blank email to php-dev+get-40070@lists.php.net to get a copy of this message
> Agreed, but are you really telling me that > > function connect(&$dsn, $persistent = false) { > if (is_array($dsn)) { > $dsninfo = &$dsn; > } else { > $dsninfo = DB::parseDSN($dsn); > } > if (!$dsninfo || !$dsninfo['phptype']) { > return $this->raiseError(); > } > > is more readable as > > function connect( &$dsn, $persistent = false ) > { > if( is_array( $dsn ) ) > { > $dsninfo = &$dsn; > } > > else > { > $dsninfo = DB::parseDSN( $dsn ); > } > > if( !$dsninfo || !$dsninfo[ 'phptype' ] ) > { > return $this->raiseError(); > } > > ? The first version is certainly more readable to me. It is nice and compact and I can see all the logic in a quick glance. The eye has to travel too far in the second case. This becomes even more true for longer code blocks as it is more likely you will need to scroll to see everything and once you scroll it becomes very difficult to keep things organized in your mind. -Rasmus

« previous php.dev (#40070) next »