Re: static vs global variable [message #172763 is a reply to message #172724] |
Mon, 28 February 2011 10:14 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma:
|
Senior Member |
|
|
sheldonlg wrote:
> On 2/27/2011 8:11 AM, Jerry Stuckle wrote:
>> On 2/27/2011 4:01 AM, The Natural Philosopher wrote:
>>> sheldonlg wrote:
>>>> On 2/26/2011 2:12 PM, The Natural Philosopher wrote:
>>>> > Lok I love PHP as a simple fast way to get web pages that have
>>>> > intelligence and talk to an SQL backend. But the be all and end all of
>>>> > programming languages?
>>>>
>>>> Who ever said _that_? You want to write microprocessor code? Of course
>>>> it not PHP. But, TNP, this a PHP news group. We use PHP for what it is
>>>> designed -- and for that it is fantastic.
>>>>
>>> That was my point.
>>>
>>> Is 50 pages of complex OOP code what it was designed for?
>>
>> If you have t0 pages of complex code, you NEED to be using OOP!
>
> I fully agree. Having been there, it was MUCH easier to keep a solid
> train of thought with OOP.
>
I would say of you have 50 pages of complex code what you need is
documentation and some overall diagram of what you are trying to achieve
that clearly outlines how bits are hung together. It might be a state
diagram, it might be a flow chart, or it might be a suite of object
specifications.
I would certainly never rely on the code itself to be self documenting.
If it were assembler, and I have written far larger code examples than
that - Assembler is hugely verbose - and it for example contained global
variables, then one necessary bit of documentation would be to insist
that anyone who writes a routine that changes that global variable add a
line 'modified by routine 'blah' written by 'coder X' in it.
Its a habit I still adopt to an extent. Even terminating curly braces
tend to have } //endif ( key alpha pressed) inserted even though the
editor I use is fully capable of collapsing each and every block.
Again the point is this, language features are no substitute for proper
documentation and clear thinking and correct chunking. And they are just
as likely to obfuscate rather than clarify if used slavishly and
inappropriately.
|
|
|