| for RuBoard |
In this chapter we discussed common design elementsidioms and
patternsin Transact-SQL code. You learned about the importance of
taking
| for RuBoard |
| for RuBoard |
I'm not a great programmer, I'm just a good programmer with great habits.
Kent Beck [1]
[1] Fowler, Martin. Refactoring:Improving the Design of Existing Code . Reading, MA:Addison-Wesley, 1999. Page 57.
I've placed this chapter as early as I have in the book because I think it's crucial to adopt good source code management habits if you're going to develop robust code for complex projects. Successfully building a sophisticated system with faulty code management practices in place is about as likely as building a space ship in a junkyard: Although it's theoretically possible, it's not very likely (Andy Griffith's Salvage I notwithstanding).
There's a tendency among
Instead, stored procedure code is
The purpose of this chapter is to refute the myth that
Transact-SQL code is not "real" source code and to establish the
value of source code management (a.k.a. version control) software
in working with it. Although you could use virtually any text
| for RuBoard |
| for RuBoard |
I suppose I should begin this discussion by talking about the benefits of storing your Transact-SQL code in a version control or source code management system. Some of these benefits aren't immediately obvious, so it's instructive to go through a few of them.
First and foremost, version controlling your code allows you to roll back to a previous version should you discover a bug or decide to scrap a code branch you've started. Because every version you've checked into the system is readily available, accessing a previous one is easy.
Second, version control systems usually provide
difference-checking facilities. These are invaluable. When you've
Third, version control systems ensure version consistency. As
you develop software and release products, your software will
naturally begin to be categorized by version. Say that you discover
six months after the release of a given product version that you
need to compile that specific version again. Your version control
system's ability to label versions and to retrieve a complete
version in one step makes this a snap. You simply find the version
with the label you want and instruct the system to retrieve it for
you. Think about how complex this process would be without the
assistance of a version control system. Once you located what you
believed were the old version's source files, you'd have to check
each oneperhaps hundreds or even thousands of themand attempt to
ensure that not only were they from the
right
version
of the application, but also from the
same
version.
And this assumes that you retained the old version's source code in
the first place. In essence, you'd be forced to become a human
version control system. Rather than creating software, you'd
Fourth, source code management systems help protect source code
from accidental loss or destruction. Because the source code is
typically stored in a central repository (a database of some type),
it's easy to back up and much easier to manage than hundreds or
thousands of files
Fifth, version control systems make change management much
easier. Because those who change code must check it out before
changing it and must check it back in before those changes take
effect, it's easy to track who's changing what in the source code.
If a change was ill advised or detrimental to the application, it
can be easily rolled back. If a change necessitates an explanation
or comments that further detail its purpose and scope, these can be
included when the file is checked back into the system. Because
changes to a given source code element can only be made by one
developer at a time, version control systems prevent developers
from
NOTE
As I write this, a new generation of version control systems is
on the horizon that changes the dynamics of source code management
in important ways. These new systems handle change management and
other source code management
| for RuBoard |