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.
Table of contents
- Basic Defensive Database Programming Techniques
- Code Vulnerabilities Due to SQL Server Misconceptions
- Surviving Changes to Database Objects
- When Upgrading Breaks Code
- Reusing T-SQL Code
- Common Problems with Data Integrity
- Advanced Use of Constraints
- Defensive Error Handling
- Concurrent Queries and Transaction Isolation Levels
- Developing Modifications that Survive Concurrency
| Pages : | 389 |
| Size : | 8.6 MB |
| Downloads: | 241 |
| Created: | 2022-02-02 |
| License: | For personal or educational use |
| Author(s): | Alex Kuznetsov |
Others related eBooks about Defensive Database Programming with SQL Server
Welcome to the world of computer programming! In this book, you will learn the essential concepts of programming using Python language.
When processing text files, the awk language is ideal for handling data extraction, report..., download free AWK Programming tutorial in PDF (572 pages) created by .
Even if you are an absolute beginner, this book will teach you all you need to know to wri..., download free C Programming tutorial in PDF (156 pages) created by Simon Long .
This book is aimed at readers who are interested in software development but have very lit..., download free Learn Programming tutorial in PDF (465 pages) created by Antti Salonen .
This book describes the Persistent Memory technology and why it is exciting the industry. It covers the operating system and hardware requirements as well as how to create development environments using emulated or real persistent memory hardware.