Re: Which is better coding style...

From: Date: Fri, 20 Apr 2001 00:22:52 +0000
Subject: Re: Which is better coding style...
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-49460@lists.php.net to get a copy of this message
Personally I use to use: if () { ... } But I found it utterly horrible to debug. I always missed a bracket, so I switch to: if () { ... } I find that even in multi-thousand line files I can flick my scroll mouse as fast as I can while still being able to follow brackets using that style. I just think it's easier to follow and clearer, but I understand why some people don't like them. I use to hate them...until I started using them :} -- Plutarck Should be working on something... ...but forgot what it was. ""..s.c.o.t.t.. [gts]"" <scott@graphictype.com> wrote in message news:KFEKLFMNHDILCMFAEKJCEELICHAA.scott@graphictype.com... > 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 (#49460) next »