A TACFUG member recently asked the “what is the best way to organize my queries” question on the mailing list.
There are lots of factors that should go into deciding the ‘best way’ to access your application data. Put these in order of importance for your application before you write any code:
- runs fast
- easy to read code
- quick to write code
- easy/quick to maintain lots of queries all in one place
- handles a lot of traffic
There are probably infinite ways you could write your database query code. I ask that you try to be considerate to the programmer that has to maintain the code next time. Think about the DBA that will have to analyze performance issues in a few years. Remember all the junior programmers that might read your code and write more of it by example.
***but***
If it’s gotta be out tomorrow, do the best you can with what you’ve got.
