Today’s post is not specific to SQL Server, but to a general developer mindset. It all started with the following tip that came up when launching Visual Studio 6.0 (yes, I do work on products written in VC++ 6.0, and I always have Visual Studio show me tips on launch).
Code, just like software architecture is a dynamic thing. Over time, the code would undergo various transformations (to incorporate various requirements), become more configurable and would require corrections as and when defects are discovered.
In my many years of experience, I have worked with two kinds of developers:
- One group comprises of those who rely solely on memory and/or search engines and believe all pieces of code can be written from scratch every time
- Then comes the other group who religiously maintain a repository of all pieces of code that they have found useful
As time passes, the later group of developers would have invested significant time in documenting, indexing and improving upon these code snippets to ensure that they can reach out to the ever evolving and self-correcting code faster. Whereas the former group of people might end up making the same mistakes over and over again.
Learning from this group, I maintain an SSMS solution that contains all the possibly re-usable and PoC level T-SQL code that I have ever written. I find that this helps me write a query faster and with improved quality.
I encourage every developer to start out with a simple repository of all possible re-usable code that they own and once it becomes a habit, watch it evolve over time. It will surely help to write the code right the first time!
Until we meet next time,