RE: [PHP] Which is better coding style...

From: Date: Thu, 19 Apr 2001 20:31:56 +0000
Subject: RE: [PHP] Which is better coding style...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-49416@lists.php.net to get a copy of this message
Definitely the second style :) (If we were talking about C(++) then the first would have even been forbidden by my companies coding standard as well as several coding standards of other companies I worked for.) The reason is this - a function has one entrypoint (duh) and one exitpoint. Jumping out of a function somewhere in the middle leads to unmaintainable code, and bugs when extending that function and that return is overlooked. But, as with the indenting and bracket placing, it is a matter of religion. They would have to torture me for three weeks to get me to place the brackets like you did in your example :) function blah() { $retval = ""; switch( $bob ) { case 1: $retval = "this"; break; case 2: $retval = "that"; break; default: $retval = "other"; break; } return $retval; } > -----Original Message----- > From: ..s.c.o.t.t.. [gts] [mailto:scott@graphictype.com] > Sent: 19 April 2001 21:31 > To: Php-General > Subject: RE: [PHP] Which is better coding style... > > > i say the first style. > > unneeded variables and other thingies just > obscure things and make it harder to maintain. > > > > -----Original Message----- > > From: Boget, Chris [mailto:Chris.Boget@wild.net] > > Subject: [PHP] Which is better coding style... > > > > Which is better? > > > > function blah() { > > switch( $bob ) { > > case 1: > > return "this"; > > > > case 2: > > return "that"; > > > > default: > > return "other"; > > > > } > > } > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: > php-general-help@lists.php.net To contact the list > administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#49416) next »