Re: PHP Standard style of writing your code
| From: | Barry | Date: | Tue, 02 May 2006 08:02:36 +0000 |
| Subject: | Re: PHP Standard style of writing your code | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235236@lists.php.net to get a copy of this message | ||
Rafael schrieb:
Show an example. I don't think you will be able to show one. But this wasted space gives you a lot more insight into the code when looking for loops,whiles,functions and such.IMHO, vertical aligned brackets can be messy when nestingrelatively-small blocks (and seems to me like a lot of wasted space) Huh?!
A couple of facts of my codding style: - I tend to always use brakets, so I ignore the fact that single lines/actions can be written without brackets, This is "your" coding style.But if you work in a team, and somone does use that because it actually is a neater way of programming. What do you intend to do?
- I try not to let lines grow larger than about 100 cols (cannot be really done with strings and other thingies, and maybe that should remain in the old 80 cols, but it's too litle space), and Never possible if you write web-applications.CLI might be possible for that but for web it's a no-go.
- I use a 4 space indentation, and that alone suffices for making a block stand clear enough It's not just about one block.I've seen stuff like: if (blah blah) { do my code! } else { oh my god! } Well, without indentation it just looks like a bunch of chars. if (blah blah) { do my code! } else { oh my god! } Even without intendations, you can clearly see that it's an if and an else here. The best part here is that you see it when you scroll through your code. without actually "reading" it.
If you have 4000 rows of code and looking for some if or switch (you are not sure) it would save you a lot of time searching for it though. And for your problem with viewing. probably try to get a 19" monitor. They are not that expencive anymore.(The CRT ones) Even on 1024x768 you see LOTSA code. -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)So, in my case, the code would be something likefunction foo( $x ) {// body...} ··· $a = foo($b); Even this is far too blocky to read.