I am looking for a good manual or introduction on how to write readable,
extensible code (in any programming language). To give you an example,
this bit looks pretty darn horrible and I just don't know how to
rephrase it to make it more concise and readable:

----------------------------- snip -----------------------------
if ( ($var>0) & ( (strlen($var)==strlen(intval($var))) or 
((strlen($var)-1)==strlen(intval($var))) ) ) {

        do stuff;

}
----------------------------- snap -----------------------------

(actually, depending on how you've configured your mail reader, or how
your terminal is set, this boolean expression may acually not appear in
one line . . . which is a problem in itself)

I am not sure why, but one problem that I happen to run up against is
that I write expressions (boolean) which get very long and because you
can't split them (what with them being conditionals in if clauses) - or
can you? - they stretch off the screen which makes my code pretty much
unreadable (I noticed that good-looking code tends to stick with, like,
70 or something characters in width).

But that's just one problem.

The stuff that I do always works, but I always have difficulties
understanding it once I come back to it after a while (the fact that I
am also lazy at commenting is not the issue - it is my belief that
well-written code should be readable as well as functional).

There must be some kind of canonical text on the subject matter, just as
there are canonical texts on SQL (Codd, Celko), C (Kernigan, Ritchie),
Perl (Wall), epistemology (Kant), the laws of motion (Newton), general
relativity (Einstein), psychoanlysis (Freud) . . . you name it.

Regards, Frank

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to