On Sat, 2003-06-28 at 13:10, Jay Fitzgerald wrote: > I have been writing PHP for almost a year now and someone on phpfreaks told > me the other day that my code was very sloppy. > > Since I want to more more into programming than design, can anyone > recommend where to learn how to make sure your code is clean, optimized and > as error-free as it can get? Even if it is the style of how to write the > code, please let me know....I know noone can be the perfect programmer, but > I would at least like to be a decent programmer :) > > Jay
I would suggest reading some coding standards from, say, the Linux kernel source, PEAR, and whatever else you can find. They'll disagree with one another, but you'll get an idea of what kinds of things people find important. One book that is simply excellent is 'Code Complete: A Practical Handbook of Software Construction', by Steve McConnell (Microsoft Press). It's pretty big but it's well written, easy to read, and usually presents a few different methods along with discussions and comparisons. Some simple tricks with PHP include using a template engine to keep your code and your output separated (i.e. don't put your PHP code directly into the HTML or vice versa--even though that's perfectly fine for small jobs, small jobs always seem to turn into bigger ones); turn on error_reporting(E_ALL) and ini_set('display_errors', true) when you're testing (you can turn them off for production) so you can make sure your script runs with no errors, notices, or warnings; writing your functions and class methods to rely on globals as little as possible so they are more easily transferable to new situations; and so on. However, the topic is pretty huge, everyone has an opinion, and I'm sure that for every suggestion I or anyone else makes there are good arguments against. Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]> +1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com -----==== Boycott Starbucks! http://www.haidabuckscafe.com ====----- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php