Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Defensive Database Programming

By Alex Kuznetsov,

High Performance SQL Server

Defensive Database ProframmingDefensive Database Programming by Alex Kuznetzov
(1st Edition, March 2010)

Download eBook (PDF): Free
Buy Printed Book: $29.99
Download ePub: Free


The goal of Defensive Programming is to produce resilient code that responds gracefully to the unexpected. To the SQL Server programmer, this means T-SQL code that behaves consistently and predictably in cases of unexpected usage, doesn't break under concurrent loads, and survives predictable changes to database schemas and settings. Inside this book, you will find dozens of practical, defensive programming techniques that will improve the quality of your T-SQL code and increase its resilience and robustness.

Nikos Vaggalis at I Programmer called it 'an indespensable guide'. See his review here.

View Related Books:


Editorial Review

Resilient T-SQL code is code that is designed to last, and to be safely reused by others. The goal of defensive database programming, the goal of this book, is to help you to produce resilient T-SQL code that robustly and gracefully handles cases of unintended use, and is resilient to common changes to the database environment.

Too often as developers, we stop work as soon as our code passes a few basic tests to confirm that it produces the 'right result' in a given use case. We do not stop to consider what other possible ways in which the code might be used in the future, or how our code will respond to common changes to the database environment, such as a change in the database language setting, or a change to the nullability of a table column, and so on.

In the short-term, this approach is attractive; we get things done faster. However, if our code is designed to be used for more than just a few months, then it is very likely that such changes can and will occur, and the inevitable result is broken code or, even worse, code that silently starts to behave differently, or produce different results. When this happens, the integrity of our data is threatened, as is the validity of the reports on which critical business decisions are often based. At this point, months or years later, and long after the original developer has left, begins the painstaking process of troubleshooting and fixing the problem.

Would it not be easier to prevent all this troubleshooting from happening? Would it not be better to spend a little more time and effort during original development, to save considerably more time on troubleshooting, bug fixing, retesting, and redeploying?

This is what defensive programming is all about: we learn what can go wrong with our code, and we proactively apply this knowledge during development. This book is filled with practical, realistic examples of the sorts of problems that beset database programs, including:

  • Changes in database objects, such as tables, constraints, columns, and stored procedures.
  • Changes to concurrency and isolation levels.
  • Upgrades to new versions of SQL Server
  • Changes in requirements
  • Code reuse
  • Problems causing loss of data integrity
  • Problems with error handling in T-SQL

In each case, it demonstrates approaches that will help you understand and enforce (or eliminate) the assumptions on which your solution is based, and to improve its robustness. Ultimately, the book teaches you how to think and develop defensively, and how to proactively identify and eliminate potential vulnerabilities in T-SQL code.


Book Details

Paperback: 200 pages
Publisher: Red Gate Books

Total article views: 7417 | Views in the last 30 days: 50
 
Related Articles
BLOG

Defensive Db Programming Chapter 03

Chapter 3 of the Defensive Database Programming Book by Alex Kuznetsov teaches us about how to “surv...

BLOG

Defensive Db Programming Chapter 02

This is the review of the second chapter of the book Defensive Database Programming.  The title of t...

BLOG

New Free eBook: Defensive Database Programming with SQL Server

Simple-Talk Publishing has released a new, free 291 page eBook called Defensive Database Programmi...

FORUM

Defensive Programming

Comments posted to this topic are about the item [B]Defensive Programming[/B] Never knew this. Had t...

FORUM

Defensive Database Programming

Comments posted to this topic are about the item [B]Defensive Database Programming[/B] I noticed the...

Tags
books    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones