Keep SQL out of code

JavaPractices says, storing SQL as text, outside of compiled code, eases maintenance significantly : 1. It minimizes the ripple effects caused by changes to the database schema. For example, if a table name or column name changes, the fix is usually an easy search and replace in a single text file. 2. For developers new to a project, having SQL all in one place makes it significantly easier to learn the database structure if an older application needs to be migrated to a new framework, then the SQL is readily available for porting to the new application. 3. If necessary, changes to SQL can even be made after deployment, by changing the text file and doing a restart or a refresh. This can occasionally be very useful. For example, if users ask for a change in the sort order of some data, then the developer can very likely implement that change without a redeployment (and maybe even without a restart, if the tools support a refresh). 4. adding support for a new relational database may become simply a matter of translating any non-portable SQL statements. Read more.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s