[thelist] PHP script design tips (long)

deke web at master.gen.in.us
Sun Sep 2 20:08:19 CDT 2001


On 2 Sep 2001, at 13:22, john corry posted a message which said:

> I have this same thing going...where I'm sort of new at scripting in
> general, but am picking up enough of the basics that I can make stuff
> work...it would just be really embarassing for any programmer to read my
> code and actually see how un-clever and un-elegant I am.

There's a difference between being clever and being elegant.

A clever solution is not particularly desirable, because it is
not clear *what* you are doing, and *why* it works.  Every
time you go in to modify the code, you have to puzzle it out
again - and if you maintain the code on a bad-hair-day, it
is going to take *forever* to get out the new bugs.

An elegant solution is straightforward and clear. You figured
out what you want to do, and your code clearly goes from point
A to point B. Every time you go in to modify the code, you can
instantly see what you need to do, and you can do it easily. 
There aren't any bugs when you write the code in the first place,
and there aren't likely to be any when you maintain it.

So you're *half* way there. And when you learn to take a few minutes
to make a pot of coffee and *think* about what you're doing before
you do it, you'll soon be most of the way there. The *fastest* way to
write good code is to keep your cotton-pickin' fingers off the keyboard
as long as you can. If it resembles being lazy, so be it. Better to write
20 lines of maintainable code that works right and works well than to
write 200 lines of crap.

deke







------------------------
 "The church is near but the road is icy; 
  the bar is far away but I will walk carefully." 
                            -- Russian Proverb




More information about the thelist mailing list