Home > Store

Test-Driven Database Development: Unlocking Agility

Register your product to gain access to bonus material or receive a coupon.

Test-Driven Database Development: Unlocking Agility

eBook

  • Your Price: $38.39
  • List Price: $47.99
  • About Watermarked eBooks
  • This PDF will be accessible from your Account page after purchase and requires PDF reading software, such as Acrobat® Reader®.

    The eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

    Watermarked eBook FAQ

Description

  • Copyright 2013
  • Dimensions: 7" x 9-1/8"
  • Edition: 1st
  • eBook
  • ISBN-10: 0-13-277645-6
  • ISBN-13: 978-0-13-277645-5

The practice of Test-Driven Development (TDD) has helped thousands of software developers improve quality, agility, productivity, and speed. In Test-Driven Database Development, Max Guernsey, III shows how to adapt TDD to achieve the same powerful benefits in database design and development.

Guernsey first explains why TDD offers so much potential to database practitioners, and how to overcome obstacles such as the lack of conventional “testable classes.” You’ll learn how to use “classes of databases” to manage change more effectively; how to define testable database behaviors; how to maximize long-term maintainability by limiting a database’s current scope; and how to use “emergent design” to simplify future expansion.

Building on this foundation, the author guides you through implementing modern TDD processes and database refactoring. He presents practical techniques for improving legacy databases; for deviating from strict TDD when necessary; and for adapting TDD to applications that persist data in file systems, XML, or serialized objects. Guernsey shows how to

•  Build a simple infrastructure to track and standardize scripts and databases
•  Define a sustainable TDD process for database design
•  Safely change a design without losing data
•  Design new databases that are lighter, leaner, simpler, more testable, and easier to change
•  Reduce design costs by eliminating duplication
•  Gradually bring the benefits of TDD, agility, and modern design to legacy databases
•  Remediate errors that find their way into database designs
•  Isolate behaviors and avoid unwanted dependencies that cause tests to fail

With this book as a guide, you will learn how to apply the proven practice of TDD to your database needs, and organize and optimize your organization’s data for a significant competitive advantage.
 

Test-Driven Database Development is the newest title in the highly respected NetObjectives Lean-Agile Series.

Sample Content

Table of Contents

Foreword      xvii
Preface      xix
Acknowledgments      xxv
About the Authors      xxvii


Chapter 1  Why, Who, and What      1
Why      1
   Agility Progressively Invades Domains Every Day     2
   Agility Cannot Work Without TDD     2
   TDD in the Database World Is a Challenge     3
Who     3
   TDD and OOP     4
   Applications and Databases     4
What     4
   Databases Are Objects     5
   TDD Works on Classes, Not Objects     5
   We Need Classes of Databases     6
Summary     7

Chapter 2  Establishing a Class of Databases     9
The Class’s Role in TDD     9
   A Reliable Instantiation Process     10
   Tests Check Objects     10
Classes in Object-Oriented Programming Languages     11
   Making Classes Is Easy: Just Make New Objects     11
   One Path: Destroy If Necessary     11
Classes of Databases     12
   Two Paths: Create or Change     12
   The Hard Part: Unifying the Two Paths     13
   Real Database Growth     13
   How About Making Every Database Build Like Production Databases?     14
   All DBs Would Follow the Exact Same Path     15
Incremental Build     15
   Document Each Database Change     15
   Identify Current Version     16
   Apply Changes in Order as Needed     16
Implementation     16
   Requirements     16
   Pseudocode Database Instantiation Mechanism     17
   Pseudocode Input     17
Summary     18

Chapter 3  A Little TDD     19
The Test-First Technique     19
   Write the Test     20
   Stub Out Enough to See a Failure     22
   See the Test Pass     22
   Repeat     23
Tests as Specifications     24
   “Tests Aren’t Tests, They Are Specifications”     24
   “Tests Aren’t Specifications, They Are Tests”     25
   Tests Are Executable Specifications     26
   Incremental Design     27
Building Good Specifications     28
   Specify Behavior, Not Structure     28
   Drive Design In from Without, Not the Other Way Around     29
   Defining the Design Inside Out     30
   Defining the Design Outside In     32
Summary     34

Chapter 4  Safely Changing Design     37
What Is Safe?     38
   Breaking a Contract Is a Little Bad     38
   Losing Data Will Probably Get You Fired     39
   Not Changing Design Is Also Dangerous     40
Solution: Transition Testing     44
   Test-Driving Instantiation     44
   Transition Testing Creation     44
   Transition Testing Addition     47
   Transition Testing Metamorphosis     51
   Why Not Use the Public Interface?     56
Transition Safeguards     56
   Read/Read Transition Tests     56
   Run by the Class of Databases on Every Upgrade     60
   Backup and Rollback on Fail     60
   Making Transition Tests Leverage Transition Safeguards     60
Summary     61

Chapter 5  Enforcing Interface     63
Interface Strength     64
   Stronger Coupling Languages     64
   Weaker Coupling Languages     65
   The Common Thread     66
   Coupling to Database Classes     66
   The Problem Is Duplication     66
Client-Object-Like Enforcement     67
   Creating Demand for a DatabaseDesign Class     67
Specifying the DatabaseDesign Class     68
   Getting Rid of Duplication with Multiple Client Platforms     70
   What Happens When Coupling Goes Bad?     71
   Eliminating Duplication Between Database Build and Client Code    71
   Decoupling Implementation from Design     72
Sticking Point: Change    73
   Designs Change Over Time     74
   Document All Versions of Design     75
   Couple to the Correct Version of the Design     77
Sticking Point: Coupling     78
   Various Clients Couple to Various Versions     78
   Having to Change Everything All the Time Is Duplication, Too     79
   Introducing the Lens Concept     83
   Virtual Lenses     85
   The “Current” Lens     89
   The “New” Lens     89
Summary     93

Chapter 6  Defining Behaviors     95
A New Group of Problems     96
   No Encapsulation     96
   Hide Everything     97
   Business Logic in the Database     97
Knowledge, Information, and Behavior     98
   Information     99
   Knowledge     102
   Behavior     102
Outside-In Development     106
   Defining the Test     106
   Growing Interface     108
   Growing Behavior and Structures     109
Justification by Specification     111
   Work Against Present Requirements, Not Future     111
   Build in Increments     112
   Limit Access to What Is Specified     112
Summary     113

Chapter 7  Building for Maintainability     115
Never Worry About the Future     116
   Look for Opportunities in the Now     116
   Design to Information     117
   Translate Info and Knowledge with Behavior     121
Guard Knowledge with Fervor and Zeal     124
   Not Changing Is the Most Dangerous Choice     124
   Keep Your Design Natural     126
Deal with the Future When It Happens     127
   Define New Design     128
   Introduce Minimal Changes     129
   Get Tests Passing     131
   Stop, Think, Refactor     133
Summary     136

Chapter 8  Error and Remediation     137
Kinds of Errors     137
   Axis: Is the Error Good or Bad?     138
   Axis: Is the Error Released or Not?     140
Dealing with Good Errors     142
   Just Fix It     142
   Document Behavior Now     143
   Trace Feature Back to Its Genesis     145
Dealing with Bad Errors     146
   Unreleased Errors     147
   Released Errors     150
   Catastrophic Errors     156
Summary     157

Chapter 9  Design     159
Structures Versus Design     160
   Structures: Execution Details     160
   Tests and Class Information     162
What Is Design?     163
   Buckets of Concepts     163
   Mandatory Part of True TDD     166
Composition and Aggregation     167
   Composition: One Thing with Multiple Parts     168
   Aggregation: Connecting Distinct Things     172
Reuse     175
   Avoid Developing the Same Thing Twice     175
   Reuse by Composition or Aggregation     177
Abstraction     178
   Identifying Opportunities for Abstraction     178
   Encapsulating Behaviors     179
   Finding Ways to Allow Variation in Dependencies     185
   Dealing with the Time Problem     186
Summary     190

Chapter 10  Mocking     191
Testing Individual Behaviors     191
   Why Encapsulate     192
   Tests Test Everything Not Under Their Control     193
   Controlling Irrelevant Behaviors from Tests     194
   Mocking Controls Behaviors     194
Mocking in Object-Oriented Programming     195
   Setup     195
   Decoupling     199
   Isolation     202
   Integration     202
Mocking in Database Design     203
   Example Problem     204
   Example Solution     205
   Composition     208
   Aggregation     210
   Designing for Testability     210
Summary     210

Chapter 11  Refactoring     213
What Refactoring Is     214
   Changing Design Without Changing Behavior     214
   In the Context of Passing Tests     215
Lower and Higher Risk Design Changes     222
   Lower Risk: Changing Class-Level Design     222
   Medium Risk: Rearranging Behavior Logic     223
   Higher Risk: Altering Knowledge Containers     225
   This Is Not an Invitation to Skip Testing     226
Summary     226

Chapter 12  Legacy Databases     227
Promoting to a Class     228
   Deducing Initial Version     228
   Pinning the Transition Behavior with Tests     231
Controlling Coupling     231
   Identifying and Locking Down to Existing Uses     232
   Encapsulating on Demand     234
Controlling Change     235
   Test-Driving New Behaviors     235
   Pinning Construction on Demand     237
   Pinning Behavior on Demand     238
   Implementing New Behavior     239
Finding Seams and Components     240
   Finding Seams     240
   Encapsulating Components     243
Summary     247

Chapter 13  The Façade Pattern     249
Encapsulation with a Façade     249
   Explanation of Façade Pattern     250
   New Test-Driven Façade Database     254
   Compositional Alternative     261
   To Encapsulate or Not    261
Strangling the Old Interface     262
   Transferring Changing Behaviors to Façade     262
   Removing Access and Features When No Longer Needed     263
Test-Driving Behaviors in the Façade Database     264
   Exposing Legacy Behaviors     265
   Another Way to Do It     265
   New Behaviors     266
Summary     266

Chapter 14  Variations     269
Having a Class Is Important—Implementation Is Not     270
Scenario: Skipping Steps     270
   Problem     271
   Solution     272
   The Right Amount of Work     273
Scenario: Deviations     274
   Problem     274
   Solution     275
   Solution Applied     277
Common Solution     281
Summary     281

Chapter 15  Other Applications     283
XML     284
   Encapsulation     284
   XSD Schemas     284
   XSLT Transitions     286
   Transition Test XSLT Changes     287
File Systems and Other Object Directories      288
   Transition Test File System Manipulations     289
   Shell Script Transitions     291
Data Objects     292
   Class Definitions Are Schemas     292
   Transition Test the Ugrader Class     294
   Code Transitions     296
Summary and Send Off     300

Index     301


Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020