Rules for Practical Programmers
Here are some observations I’ve gathered from writing a variety of programs in PHP over the last year. Do you have one I should add? Please share it and post it in the comments.
1) Don’t waste time re-inventing the wheel unless you can make a significantly better one.
Custom frameworks have their advantages, but are really necessary only if you are developing a particularly unusual project or actually have time to invest in writing framework. There are several great frameworks out there which are mature, tested, and have communities, all time-saving assets which no business-smart programmer should overlook.
Can’t find a framework that suits perfectly? Consider forking one.
2) Pretty code syntax should not be more important than re-usable code.
Case in point: static class methods nice and easy to use, but only if you don’t ever need to extend them (that is, until PHP 5.3 is production-ready). Make code decisions on the basis of functionality and intended use rather than “prettiness.”
3) Learning to use design patterns will save time in the long run, but don’t overdo it.
Remember the law of diminishing returns.
4) Comment religiously, and make your code easy to read, too.
This involves descriptive variable names, following code style conventions, etc. Make comments useful: “# Assign the variable” tells me nothing I can’t already see.