Re: Evolving style



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

.



Relevant Pages

  • Re: Feedback?
    ... chunk is my work so I was interected in learning what to fix in this chunk. ... I am afraid that you have lost me. ... You are also writing an unvalidated input variable ...
    (comp.lang.php)
  • Re: Critique rules
    ... I've lost that skill. ... One certain way of not improving your writing is to stay within your ... I was trying to talk less about skills, then about learning strategies. ... One part of learning is finding the right teacher. ...
    (rec.arts.sf.composition)
  • Re: good riddance (to bad rubbish)
    ... >>remarks. ... take care and maybe one day you'll find other way of writing ... > see this newsgroup as your own personal learning centre ... > If you really want people to say, in your language, "Spierdalaj" then ...
    (uk.culture.language.english)
  • Re: A reasonable project.
    ... I've been learning C over the past 6 or so months, by writing small ... programs and reading a couple of books on the language. ... force me to learn how to write makefiles, proper structure of header files ...
    (comp.lang.c)
  • Re: Some Advice.
    ... >>am learning that naming is far more important in C than in Perl. ... >>Writing a program and learning is very fustrating. ... Perl was really bad for that in complex data structures. ... I hope that my code can be seen and I get some advice why ...
    (alt.comp.lang.learn.c-cpp)