Jump to content

What's the advantage of coding this way


niche
 Share

Recommended Posts

What's the advantage of coding this way:

$headers =  "From: \"Niche\" <somebody@example.com>\r\n" .$headers .= "MIME-Version: 1.0\r\n"	    . "Content-Type: multipart/mixed; boundary=\"$bound_text\"";

instead of this way?:

$headers =  "From: \"Niche\" <somebody@example.com>\r\n" .		   "MIME-Version: 1.0\r\n"	    . "Content-Type: multipart/mixed; boundary=\"$bound_text\"";

Could it just be preference?

Link to comment
Share on other sites

Guest So Called

No difference except your own ideal of readability. (Your first example has a syntax error. I'm sure you meant to terminate the first line with a semicolon. IMO too many programmers spend too little time on the subject of readability, which code if easier to read is easier to maintain. Big clue: If any of you programmers are not using tabs or tabulated code listings then you have missed an essential part of programming for ease of maintenance, and for ease of understanding your own code for debug purposes. Neat code or so called "pretty" code is easier to maintain, easier to debug. But it's difficult to define, just like beauty is difficult to define but you know it when you see it..

Link to comment
Share on other sites

Guest So Called

There's two different schools on that (bracket placement), as your examples show. There is no absolutely correct way, and there is no objective way to say one is better than the other. All that can be said is to stick with either one or the other throughout your entire project. I prefer this way:

if (condition {	// code} else {	// more code}

Code is more readable and easier to debug and maintain if it has a uniform style throughout. IMO code with no tabs is a PITA to work with.

Link to comment
Share on other sites

Guest So Called

Yes, I meant horizontal tabulation in some/any form, whether 2, 4 or 8 spaces, tabs, etc. Myself I prefer tabs first, or any standard second, but what's really worst is mixed standards or no horizontal tabs/spaces at all.

Link to comment
Share on other sites

There's two different schools on that (bracket placement), as your examples show. There is no absolutely correct way, and there is no objective way to say one is better than the other. All that can be said is to stick with either one or the other throughout your entire project. I prefer this way:
if (condition {	// code} else {	// more code}

Code is more readable and easier to debug and maintain if it has a uniform style throughout. IMO code with no tabs is a PITA to work with.

wouldnt this code you place above give you an error? you forgot to close up, and i perfer to code like this:
if(){}else{}

its more readible to me, and i tent to follow along better whiles codes like this

if($this->$peter){$this->row}

i tends to go off track when reading those like that, even tho i know what its saying

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...