Too many times I walk in to a new job and their main complaint is performance problem with their web site. Often, when a web site is new, and has relatively low traffic, poor coding practices and structure doesn't really have much impact on the visitor experience. But as the database grows, visitors increase and the server and site is put under greater demand, performance issues start to make a difference. Little things like which control structures to use in a given situation, how to manage database connections, and record set handling, start to show if it was good or bad.
This isn't a matter of the platform/language wars, many people concentrate to much on that level of thought. The real battle is using whatever the chosen platform/language is to it's fullest.
No matter what the platform is, don't be opening and closing database connection inside each function with each query. The connection is the most expensive part of the process, open your connection, do all the work you have to do and close the connection. Don't nest queries if a larger, better written SQL statement can get everything at once.
Don't use a long series of "if" statements if you know only one "if" will match, use a switch/case, or at the very least one if with a few else if/else's tossed in to make sure processing stops once the match is found. if you run one long series of "if" statements, and the first one matches, the code is going to check the rest anyway, if you use if/else if/else type of structure, once the match is found, it will exit that structure and move on, saving execution time.
Do not over think and over code a project. This is my pet peeve of WYSIWYG editors, as they typically, though not always, generate bloated, large code that if written by hand by a knowledgable coder, can be smaller and quicker.
Wednesday, March 19, 2008
Using Proper Code for the Job
Posted by
dB Masters
at
7:21 AM
Labels: Web Development
Subscribe to:
Post Comments (Atom)


0 comments:
Post a Comment