Re: How to write code: how wrong am I?
| From: | Dotan Cohen | Date: | Tue, 22 Feb 2011 14:10:38 +0000 |
| Subject: | Re: How to write code: how wrong am I? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311520@lists.php.net to get a copy of this message | ||
On Tue, Feb 22, 2011 at 15:00, Andy McKenzie <amckenzie4@gmail.com> wrote:
> I'll be the first to tell you that I'm not a great programmer, so my
> take may not be worth a lot. However, this is pretty close to how I
> write. Not exactly, but close. I also always label open and closing
> brackets on everything, unless the brackets are less than three lines
> apart. For instance, I might find myself writing:
>
> if($foo == 'bar')
> { # Begin foo=bar test
> # If foo=bar, do a lot of things.
>
> } # End foo=bar test
>
> Then I go back and fill in the conditional stuff.
I also do something similar, I debated writing about that as well:
class someClass{
function someFunction() {
if (true) {
// Some Code
}
} // end someFunction
} // end someClass
I don't strictly subscribe to a three-line limit, but whatever feels
reasonable at the time. Often that depends on the complexity of
surrounding code.
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com