Database Reference
In-Depth Information
Programming best practices
Developing application software is complicated. Some of the approaches to help man-
age that complexity are so popular that they've been given simple acronyms to re-
member them. Next, we'll introduce some of these principles and show how server
programming helps make them easier to follow.
KISS - keep it simple stupid
One of the main techniques to successful programming is writing simple code. That
is, writing code that you can easily understand three years from now, and that others
can understand as well. It is not always achievable, but it almost always makes sense
to write your code in the simplest way possible. You may rewrite parts of it later for
various reasons such as speed, code compactness, to show off how clever you are,
and so on. But always write the code first in a simple way, so you can absolutely be
sure that it does what you want. Not only do you get working on code fast, you also
have something to compare to when you try more advanced ways to do the same
thing.
And remember, debugging is harder than writing code; so if you write the code in the
most complex way you can, you will have a really hard time debugging it.
It is often easier to write a set returning function instead of a complex query. Yes, it
will probably run slower than the same thing implemented as a single complex query
due to the fact that the optimizer can do very little to code written as functions, but
the speed may be sufficient for your needs. If more speed is needed, it's very likely to
refactor the code piece by piece, joining parts of the function into larger queries where
the optimizer has a better chance of discovering better query plans until the perform-
ance is acceptable again.
Remember that for most of the times, you don't need the absolutely fastest code. For
your clients or bosses, the best code is the one that does the job well and arrives on
time.
Search WWH ::




Custom Search