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

From: Date: Fri, 20 Apr 2001 03:51:02 +0000
Subject: RE: [PHP] Which is better coding style...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-49487@lists.php.net to get a copy of this message
egads... it distracts me to no end to see an if-else block broken up that way... to me seeing if( some expression ) { some action } else { some other action } is the most normal thing in the world. Same goes for the { at the end of the expression, such as for( ... ) { } while( ... ) { } function SomeFunc() { } That's how I've written all my C, C++, JavaScript, ColdFusion CFSCRIPT, and now PHP. Joseph E. Sheble a.k.a. Wizaerd Wizaerd's Realm Canvas, 3D, Graphics, ColdFusion, PHP, and mySQL http://www.wizaerd.com ================================= > -----Original Message----- > From: ..s.c.o.t.t.. [gts] [mailto:scott@graphictype.com] > Sent: Thursday, April 19, 2001 2:05 PM > To: Php-General > Subject: RE: [PHP] Which is better coding style... > > > OOooo... > > it drives me nuts when i see beginning brackets > on seperate lines ;) > > i like to start brackets on the same line as the > statement and finish them on a line of their own. > > if (...) { > } > else { > } > > (it drives me nuts to see "} else {" also) > > > > -----Original Message----- > > From: Sander Pilon [mailto:sander@3dnews.net] > > Sent: Thursday, April 19, 2001 4:32 PM > > To: 'Php-General' > > Subject: RE: [PHP] Which is better coding style... > > > > > > 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 > > > > > > > > > > > > -- > > 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 > > > > -- > 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 (#49487) next »