Re: Evolving style
- From: The Natural Philosopher <tnp@xxxxxxxxxxxxxxx>
- Date: Fri, 22 May 2009 15:57:51 +0100
Erwin Moller wrote:
The Natural Philosopher schreef:C. (http://symcbean.blogspot.com/) wrote:On 22 May, 10:42, Bill H <b...@xxxxxxxxx> wrote:I started using php about a year ago after using perl for 8 years and
find I am now using it almost exclusively for my web sites. I don't
consider myself an expert and am learning new things every day.
I have recently noticed that my programming style is evolving as I
learn more, making more use of classes, using ()?: instead of if(),
better handling of $_POST information, writing more modularized code
versus linear code etc.
So now, when I go to work on something I wrote a few months I see
that, though it works, it could be written better. The question is,
should I rewrite this old code as my knowledge grows and style changes
or should I wait till my learning curve stabalizes?
Coding style is about preventing errors and making code more readable.
Which is of course correct, but says nothing about who ultimately will be reading it.
If its got no errors, chances are no one ever will, unless it needs modification.
I've gone back to old code and cant even remember writing it.
I have that all the time. ;-)
Which probably means you should write it so that an older you can understand it. ;-)
The best I feel I can hope for its to say to myself 'What bit of what I am writing do I find hard to understand' and at least document that a lot.
I've often resorted to the old assembly dictats
"Write the whole thing out in English pseudo code first, and then insert the actual code bits ion between that, and comment any line that isn't patently obvious'
If people spent as much time worrying over comments and documentations as over 'how to use the language' I think it would be better.
I MUCH prefer
/* In this function, $y is the offset from the actual window top, in pixels /. We just add 4 to it here and return it.*/
function k($y)
{
$y+=4;
return $y;
}
to:-
function ThisAdds4ToYIndexInPixelsFromTheWindowtop($YPixelsOffsetFromWindowTop)
{
etc..
}
Simply because a human reader is more tolerant of typing mistakes than a computer ;-)
Its all part of a retrograde process that's been going on ever since Macro assembler was invented, I reckon ;-) Trying to make the process of telling a binary coded machine what to do, appear to be some excercise in natural language. Which it ain't, never was and probably never will be.
Some of the best minds have wasted years of their time to try and make it possible for idiots to program computers.
And the rest, as they say, is Microsoft.
I am sure I will get the full force of the flame throwers turned upon me for that though.
Regards,.
Erwin Moller
- References:
- Evolving style
- From: Bill H
- Re: Evolving style
- From: C. (http://symcbean.blogspot.com/)
- Re: Evolving style
- From: The Natural Philosopher
- Re: Evolving style
- From: Erwin Moller
- Evolving style
- Prev by Date: Re: Evolving style
- Next by Date: Re: Evolving style
- Previous by thread: Re: Evolving style
- Next by thread: Re: Evolving style
- Index(es):
Relevant Pages
|