Position of variable definitions [was: Re: [nycphp-talk] php script]
David Krings
ramons at gmx.net
Mon Feb 25 12:51:57 EST 2008
Allen Shaw wrote:
> But the temporary
> variables used within a function or method are usually only relevant in
> the lines where they're being used. Document them where you use them,
> and save yourself the nightmare of keeping a single comprehensive
> doc-block up to date.
That is indeed a pretty good argument and I will let it sink for a while, but
I can't come up with any disadvantages to that.
>> Allen also wrote "Again, it totally depends on the logical flow of
>> your scripts". Why/when would the location of variable definitions
>> depend on the logical flow of the script?
> If he needs to use that value in the beginning of his script, he'll have
> to define it there. Where it's used is determined by how he wants the
> script to work. I still recommend defining/initializing/documenting it
> as close as possible to the place it's used.
Oh, ok, that is what you meant.
Thanks for the response, very helpful.
David
More information about the talk
mailing list